- This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
Viewing 5 posts - 1 through 5 (of 5 total)
- The forum ‘Back End’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › Back End › Removing the admin bar and backend from normal users like here on CSS Tricks
Hello Everyone,
I was wondering how does CSS Tricks completely hide the whole backend and dashboard so well?
Thanks
What do you mean by “hide the backend” exactly?
Sorry, I mean like hiding the dashboard from logged in users and such.
I pretty much have a general idea using:
methods like current_user_can(‘role here’)
I don’t think there’s a good reason to have a user looking at the dashboard.
Thanks for the reply :)
Add add_filter( 'show_admin_bar', '__return_false' );
to your functions.php file.
You can use this
add_action( 'init', 'blockusers_init' );
function blockusers_init() {
if ( is_admin() && ! current_user_can( 'administrator' ) &&
! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
wp_redirect( home_url() );
exit;
}
if( ! current_user_can( 'administrator' ) ) {
add_filter( 'show_admin_bar', '__return_false' );
}
}