I am currently in the middle of a project creating a user database in WordPress and I needed to remove the toolbar on the front end of the website so that users didn’t have access to it. This process is very simple to do.
The basic function that accomplishes this is:
You can add this to your functions.php file, or anywhere in your theme above the wp_footer() function.
If you want to use this only for specific roles, try the following example:
Alternatively, you can create a function to do this if you are developing a plugin, etc.
The only remaining issue with this fix is that there is still a 28px margin at the top of the page that WordPress adds to make space for the admin bar. The best way to remove this is to add a callback to the admin-bar function to remove this space. You should add this into your themes function.php file directly:
[cc lang=”php”] ‘__return_false’));
As a closing note, these methods only work on the toolbar on front end of your site, not on the backend.