Change published to pending after update

Change Published to Pending


Published to Pending

What to do if you wish to approve all changes made into published post by their authors? It’s possible by changing post status from ‘Published’ to ‘Pending Review’ automatically. You need just add a piece of code placed below to your current theme 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.

Code below allows you to achieve a described effect:

add_action('save_post', 'submit_for_review_update', 25 );
 
function 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);
    }
}

You can add this code into your active theme functions.php file or setup it as a Must Use plugin.

P.S. Thanks to @Ravi for ideas how to enhance this recipe.