• Resolved Anonymous User 14123315

    (@anonymized-14123315)


    I think I found a bug related to custom post types via wp_insert_post.
    If you use the simplest version of inserting a post, it creates 2 posts in the custom post type. If I disable this plugin, it only creates one. I love this plugin so I would love to keep it. Is there a fix for this?

    add_action(‘user_register’, ‘create_bio_post_on_register’, 10, 1);

    function create_bio_post_on_register($user_id)
    {
    $create_bio = array(

    ‘post_title’ => $_POST[‘first_name’] . ” ” . $_POST[‘last_name’],
    ‘post_status’ => ‘draft’,
    ‘post_author’ => $user_id,
    ‘post_type’ => ‘bio’
    );

    // Insert the post into the database
    $create_bio_post_id = wp_insert_post($create_bio);
    }

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Javier Carazo

    (@carazo)

    Sorry but this is not an issue related with this plugin.

    user_register is a hook provided by WordPress.

    Thread Starter Anonymous User 14123315

    (@anonymized-14123315)

    Maybe there is another hook that you could recommend?

    Plugin Author Javier Carazo

    (@carazo)

    Sorry, no I have no idea.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Custom Post Type with wp_insert_post’ is closed to new replies.