Skip to content

Instantly share code, notes, and snippets.

@vutruso
Created December 2, 2019 13:41
Show Gist options
  • Save vutruso/e208be26b1b27dde06023daf6979a863 to your computer and use it in GitHub Desktop.
Save vutruso/e208be26b1b27dde06023daf6979a863 to your computer and use it in GitHub Desktop.
Public > Pading status if author edit post
add_action('save_post', 'vts_submit_for_review_update', 25 );
function vts_submit_for_review_update($post_id) {
if (empty($post_id)) {
return;
}
$post = get_post($post_id);
if (!is_object($post)) {
return;
}
if ($post->post_type=='revision') {
return;
}
$current_user = wp_get_current_user();
if (in_array('author', $current_user->roles) && $post->post_status=='publish') {
$my_post = array(
'ID' => $post_id,
'post_status' => 'pending',
);
remove_action('save_post', 'submit_for_review_update', 25);
wp_update_post($my_post);
add_action('save_post', 'submit_for_review_update', 25);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment