目前我正在制作帖子,产品通过帖子显示为草稿,产品不会显示在前端,但是有一种方法可以在上传内容时完全重新提升用户。
add_action('init', 'make_editor_post_drafted');
function make_editor_post_drafted(){
$user = wp_get_current_user();
if ( in_array( 'editor', (array) $user->roles ) ) {
$user_ID = get_current_user_id();
$users_query = new WP_Query( array(
'post_type' => array('product','post'),
'meta_value' => $user_ID,
) );
if ( $users_query->have_posts() ):
while ( $users_query->have_posts() ): $users_query->the_post();
wp_update_post( array('ID' => get_the_id() , 'post_status' => 'draft' ));
endwhile;
endif;
} //end if
} //end function