当然可以-您可以使用wp_insert_post_data filter:
function no_going_back_to_draft($slashed_data , $post_data) {
if($slashed_data[\'post_status\'] == \'draft\') { // we\'re only interested in posts being saved as "drafts"
$user = wp_get_current_user();
if ( in_array( \'no-going-back-to-draft-role\', (array) $user->roles ) ) { // we\'re only interested in users with that special, restricted role
$post = get_post($post_data[\'ID\']);
if(
$post && // if $post == null, it\'s a new post, so it\'s definitely never been published yet...
($post->post_status != \'draft\') // so *any other status* but draft can\'t be brought back to "draft" by this partuclar user
) {
$slashed_data[\'post_status\'] = $post->post_status; // override the post\'s status: set it to the current value in the db
}
}
}
return $slashed_data;
}
add_action( \'wp_insert_post_data\', \'no_going_back_to_draft\', 10, 2 );
希望这有帮助!