How to disable the backend editor option for Teacher Role

Kindly follow the below steps for disable the backend dashboard access for teachers role.

Open the file in this path /wp-content/themes/theme-folder/function.php using some editor like DreamWeaver.

If you have activated the child theme then Open the file in this path /wp-content/themes/childtheme-folder/function.php using some editor like DreamWeaver and append the below code.

add_action('admin_init', 'disable_dashboard'); function disable_dashboard() { if (current_user_can('teacher')) { wp_redirect(home_url()); exit; } }

function disable_admin_bar_for_teachers(){ if ( is_user_logged_in() ): global $current_user; if( !empty( $current_user->caps['teacher'] ) ): add_filter('show_admin_bar', '__return_false'); endif; endif; } add_action('init', 'disable_admin_bar_for_teachers', 9);

Rate This Article

(26 out of 70 people found this article helpful)

Leave A Comment?


The reCAPTCHA verification period has expired. Please reload the page.

This site uses Akismet to reduce spam. Learn how your comment data is processed.