#1998
Vladimir
Keymaster

Try this code:


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);
    }
}