Creating Posts from Formidable Form requests.
Recently I have been wanting to generate user created posts from a project I have been working on in WordPress.
One functionality that I came across was using Formidable to create posts. I'm not sure if this is the BEST action for what I want specifically, but I can give you a run down of how this works. We will cover how to create a post, and how to query items from the posts, specifically custom fields created by a formidable form.
So what do we do first?
I had a lot of things going on with my idea which involved uploading photos, using image filters and posting to custom post types. We can get into that later. Lets start with the basics. And maybe an image uploader ;).
1: Create a form for all the content. Lets use the following fields.
- Title (single line text field)
- Content (Rich Text Field)
- Image (File Upload)
- Any custom field you want! 😀
2: Go to the settings section of your form.
3: Under settings you should see a "create posts" side-tab, go to that side tab and it should give you the instructions on how to create a post.
4: Specify the post variables
- Post Type
- Post Title (can be Title Field)
- Post Content (Content Field)
- ect.
5: To add custom fields, be sure to go to the bottom and click "Add" under the custom fields section.
6: Create a custom field that is your image field. Send that on to the post.
Now here is the kicker. You need to show your post image in your actual post.
So create a new post content file. something like content-imageuploads.php or something like that.
Now set the content up any way you want.
To call your image, here is your code.
$postMeta = get_post_custom(get_the_ID());
foreach ($postMeta['Image'] as $image => $value)
{
echo '<img alt="" src="'. wp_get_attachment_url($value) .'" width="600" />';
}