Reply To: Restrict access to wp-admin and disable admin bar for forum participants
Hi Robin,
thank you for your reply. The code in that resource isn’t quite satisfactory but it gave me a head start.
I came up with the following function to disable the wp toolbar:
// disable wp toolbar on the frontend of website for role:'subscriber'
function disable_admin_bar() {
if (current_user_can( 'subscriber' ) ) {
show_admin_bar( false );
}
}
add_action( 'after_setup_theme', 'disable_admin_bar' );
and the following to disable wp-admin:
// not allow access to wp-admin backend for role:'subscriber'
function sub_no_read_wpadmin(){
$role = get_role( 'subscriber' );
$role->remove_cap( 'read' );
}
add_action( 'admin_init', 'sub_no_read_wpadmin' );
Hopefully this is sound. Do you see any problems with this implementation?