Recently I was working with a membership WordPress website. I added login form and write some code for that.
I checked the login code and that was working but I realize that logged in user can view admin bar and unknown user can also access wp-admin dashboard then I search and found the following code. It is really useful.
If you want to hide admin tool bar only for users:
add_action('after_setup_theme', 'remove_admin_toolbar'); function remove_admin_toolbar() { if (!current_user_can('administrator') && !is_admin()) { show_admin_bar(false); } }
But if you want to hide for all type of users:
add_action('after_setup_theme', 'remove_admin_toolbar'); function remove_admin_toolbar() { show_admin_bar(false); }