当某一类型的用户尝试更新其帖子时,是否有一种有效的方法将帖子状态从“已发布”更改为“草稿”。我试过这样的方法
function change_post_status($post_id)
{
if(current_user_can(\'rolename\'))
{
$current_post = get_post( $post_id, \'ARRAY_A\' );
$current_post[\'post_status\'] = \'draft\';
wp_update_post($current_post);
}
}
add_action(\'pre_post_update\',\'change_post_status\');
代码在我看来很好,但由于某些原因,它不能正常工作,我认为它会创建一个无休止的循环(迫使我重新启动SQL server)。