
Published to Pending
functions.php file. It works for users with ‘Author’ role. If you wish to change it, then change ‘author’ in the code to role name you wish to use.Is that all you need to do? No. You should remove ‘publish_posts’ capability from your users, otherwise user can to publish pending post himself again. Use User Role Editor plugin for that.
Do you wish to see how does this hack work? Let’s proceed with short video demonstration.
Code you should use to achieve shown effect is
function published_to_pending($post_id) { global $post; if (!is_object($post)) { return; } if (current_user_can('author') && $post->post_status=='publish') { // stop recursion call remove_action('save_post', 'published_to_pending'); // update the post, which calls save_post again wp_update_post(array('ID' => $post_id, 'post_status' => 'pending')); // re-hook this function back add_action('save_post', 'published_to_pending'); } } add_action('save_post', 'published_to_pending'); |



