这是因为wp_insert_post
在添加条款之前检查当前用户功能:
if ( current_user_can($taxonomy_obj->cap->assign_terms) )
wp_set_post_terms( $post_ID, $tags, $taxonomy );
要绕过此问题,请使用
wp_set_object_terms
而是在之后
wp_insert_post
添加条款:
$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\'
);
$new_id = wp_insert_post( $new_post );
wp_set_object_terms( $new_id, $term_id, \'publicationstype\' );