I’m looking for a way to disable text tab on wordpress text-edito (red square on the pic) for all my users roles except ADMINISTRATOR because i don’t want them to have the possibility to add javascript code on the pages. I also looking for a way to add justify icon to the text-editor (like you see on the pic in red too).

now i found a way to hide text tab for all users with the code bellow

    function my_editor_settings($settings) {
    $settings['quicktags'] = false;
    return $settings;
    }

    add_filter('wp_editor_settings', 'my_editor_settings');

How can add an exception for ADMINISTRATOR role?

enter image description here

1 Answer
1

For disabling the text tab for all users except administrators, you can add the following:

function my_editor_settings($settings) {
    if ( ! current_user_can('administrator') ) {
        $settings['quicktags'] = false;
        return $settings;
    } else {
        $settings['quicktags'] = true;
        return $settings;
    }
}

add_filter('wp_editor_settings', 'my_editor_settings');

Leave a Reply

Your email address will not be published. Required fields are marked *