How to keep the capability of users and disable Gutenberg editor in WordPress?

I disabled Gutenberg web builder/ editor using the following code:

add_filter( 'use_block_editor_for_post', '__return_false' );

Somehow this impacted contributor’s capability to submit post for review, now contributor’s posts are not asking any approval. I tried to remove the capability manually, by writing this code,

$role->remove_cap( 'publish_posts' );

but this code also has no effect at all.

It seems a WordPress bug, any suggestion?? It’s showing the same results with https://wordpress.org/plugins/classic-editor/ plugin too.

How to keep the capability of users and disable Gutenberg editor in WordPress?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

add these lines in your ‘functions.php’, it will work

//if not gutenberg reapprove posts
add_filter( 'wp_insert_post_data', 're_aprove', '99', 2 );
function re_aprove( $data, $postarr ) {
    //check if current user is not admin
    if ( ! current_user_can( 'manage_options' ) ) {
        if ( 'publish' === $data['post_status'] ) {
            $data['post_status'] = 'pending';
        }
    }
    return $data;
}


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x