0

As per the title really, I'm wondering if there's a way to hide the main content editor for posts and pages from certain users / roles but let everyone else see it?

I believe you can hide it completely using this code

function remove_pages_editor(){
    remove_post_type_support( 'page', 'editor' );
}   
add_action( 'init', 'remove_pages_editor' );

but I wouldn't have the first idea of how to adapt that so that it only affect certain users / user roles?

Any help would be greatly appreciated.

Thanks.

0

Actually why is it when I ask these things I come across the answer?

Not the exact answer I was after but found how to hide the content editor completely so then just put in a check for a certain user ID and it's working.

Pretty sure this wouldn't do anything harmful anywhere as it's just hiding the editor so nothing will be lost at any point hopefully?

function remove_pages_editor(){

    $user = wp_get_current_user();
    if ($user->ID == 2) {
        remove_post_type_support( 'page', 'editor' );
    }
}   
add_action( 'init', 'remove_pages_editor' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.