I am using wp_insert_post to post the data on my website from front end. By default this is assigning every post to the admin whether I am logged in or logged out. How can I set it to judge whether admin is logged or it is a other user then assigning post accordingly. One more thing there are two admin and it is assigning post to both. How can I prevent it to do so. The code I am using to wp_insert_post is

$firstname = $_POST['hfirstname'] ; 
$lastname = $_POST['hlastname'] ; 
$my_post = array(
  'post_title'    => $contrititle,
    'post_type' => 'contribute',
    'post_status' => 'publish',
$contributeid = wp_insert_post( $my_post );
        update_post_meta ($contributeid, 'first_name', $firstname) ; 
        update_post_meta ($contributeid, 'last_name', $lastname) ; 

Read more here: How to assign author(admin or non-admin) to the post using wp_insert_post?


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , , ,

Wordpress related questions and answers: