Saving data from frontend into the database

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?

Read More

Can anyone give me some direction to a good example?

Thanks.

Related posts

Leave a Reply

1 comment

  1. 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 );