How to allow Contributors to edit their own posts, whilst still needing to be reviewed by an admin?

Steps for setting edited posts by contributors to “pending review”:

1. Adjust Contributor Capabilities

Your modifications to the contributor role are appropriate for allowing them to edit their posts. Ensure they can edit posts but cannot publish them.

2. Automatically Revert Posts to “Pending Review” on Edit

Add the following code to your functions.php. This function sets a post to “pending review” when a contributor edits a previously published post:

function set_post_pending_review( $post_ID, $post_after, $post_before ) {
    if ( $post_before->post_status === 'publish' ) {
        $user = wp_get_current_user();
        if ( in_array( 'contributor', $user->roles ) ) {
            remove_action( 'post_updated', 'set_post_pending_review' ); // Avoid infinite loop
            wp_update_post( array(
                'ID'          => $post_ID,
                'post_status' => 'pending'
            ) );
            add_action( 'post_updated', 'set_post_pending_review', 10, 3 ); // Re-add the function
        }
    }
}
add_action( 'post_updated', 'set_post_pending_review', 10, 3 );