Disable WP Dashboard access for some custom user role
-
Hi, It took me hours trying to figure this out. But still not able to solve it. I found this article, however, I don’t really understand the snippet or if it is able to achieve what I want.
Say I have ‘admin’, ‘manager’, ‘student’, ‘client’ 4 roles in total.
I only want to allow admin and manager roles able to access the wp dashboard.
How can I do it with this plugin or with eh function mentioned in the article below? Thankshttps://www.role-editor.com/documentation/hooks/ure_role_additional_options/
add_filter( 'ure_role_additional_options', 'add_prohibit_access_to_admin_option', 10, 1 ); function add_prohibit_access_to_admin_option($items) { $item = URE_Role_Additional_Options::create_item( 'prohibit_admin_access', esc_html__('Prohibit access to admin', 'user-role-editor'), 'init', 'prohibit_access_to_admin' ); $items[$item->id] = $item; return $items; } function prohibit_access_to_admin() { if ( is_admin() && !wp_doing_ajax() ) { wp_redirect( get_home_url() ); } }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Disable WP Dashboard access for some custom user role’ is closed to new replies.