Here is my Code, it works fine When i try to post data from front end if Logged in as admin, but if i logged in as a subscriber code works fine but it is not inserting the taxonomy term i select, here is the code..
$new_post = array(
'post_title' => $postTitle,
'post_content' => $post,
'post_status' => 'publish',
'post_date' => date('Y-m-d H:i:s'),
'post_author' => $user_ID,
'post_type' => 'publications',
'tax_input' => array( 'publicationstype'=> $term_id )
//'post_category' => array(6)
);
wp_insert_post($new_post);
here ‘publicationstype’ is the custom taxonomy, is there any one, who can help me!! thanx in advance
It’s because within
wp_insert_post
current user capabilities are checked before adding the terms:to get around this, use
wp_set_object_terms
instead afterwp_insert_post
to add the terms: