Try using this code instead!
function remove_admin_bar() {
if (!current_user_can('administrator') && !is_admin()) {
show_admin_bar(false);
}
}
Hi Davood,
Thank you for your reply.
Already tried that but it doesn’t work.
Unchecking it manually via “Users> your profile > uncheck Show Toolbar when viewing site” has to work without the use of plugins or code snippits but it doesn’t.
I’ve migrated the site from another domain where I also experienced the same problem and reinstalled WordPress in the hope it would fix the problem, no luck.
-Reinstalled WordPress
-Switched themes
-Deactivated plugins and activated one by one
Maybe has something to do with the database?
I do not think it has anything to do with the database. Are you sure you are adding the code to the themes functions.php file? If so, then please tell me what themes you are using the code with because I suspect it would be an issue with the theme not supporting this code and you may need to contact their support for help with this.
Yes, i’m adding the code to the functions.php in my child theme and also tried adding it to the parent themes functions.php.
I also thought it had something to do with the theme but it happens with every theme I use.
The weird thing is that with some plugins or codes the admin for administrator does hide but for the other user roles the admin bar remains present.
Then there is a plugin conflict. It is either a plugin conflict or a theme conflict… if you say it happens with every theme you use including out of the box ones like Twenty Sixteen then it is a plugin conflict.
I’ve found the problem!
I’ve deactivated the Maintenance plugin from fruitfulcode and everything is behaving like it should.
Thanks for the help.
Glad you found the culprit.
We are here to help any time. Feel free to post here anytime!