Reputation: 10888
I am in the middle of creating a plugin. The plugin shows a from on the frontend to the end user. I want the data the user enters to be saved into the database. So I created a custom post type.
So now what I am looking for is how can I save data entered into the form as a record in the new custom form type? At which out of the box functions / hooks should I look?
Can anyone give me some direction to a good example?
Thanks.
Upvotes: 1
Views: 1738
Reputation: 27092
You're looking for wp_insert_post(). In your plugin, you'll just want to add it to your form processing. An example:
$post = array(
'post_name' => 'some-slug',
'post_title' => 'Some Title',
'post_status' => 'draft',
'post_type' => 'custom_post_type'
);
wp_insert_post( $post );
Upvotes: 2