AI Verified

Name

Hiding "Show Toolbar when viewing site" checkbox on profile page for specific user roles

About

Have a user role that you want to hide "Show Toolbar when viewing site" checkbox on the profile page? This will remove the checkbox on specific user roles so Admins can control who has the admin toolbar show on the front end.

Language

PHP

Rating

Voted: 0 by 0 user(s)

How to Setup Snippet

Paste code into snippet area and replace 'editor' with the name of your specific user role

Codevault

Cache-of-Records

Scroll down to see more snippets from this codevault.

Wordpress Compatability

The author has indicated that this snippet is compatable up to wordpress version: 6.1

Our AI bot has checked this snippet is compatable up to wordpress version: 6.1

Code Snippet Plugin Sync

Free & Pro

Download this snippet by clicking the download button, then head over to the Code Snippet Plugin settings in your wordpress admin dashboard, select the import menu then upload this file to import into your wordpress site.

Pro Only (Coming Soon)

You will be able to click a button and sync this snippet to your wordpress site automatically and from your dashboard manage all code snippets across all your wordpress sites that have the Code Snippets Pro plugin installed.

History

Last modified:

19/08/2023

Important Note

This snippet has the following status:

AI Verified

This snippet has been tested by our AI bot, see any comments below.

AI Bot Comments:

Found 0 vulnerabilities

Hiding "Show Toolbar when viewing site" checkbox on profile page for specific user roles

 
                    
1function hide_toolbar_option_for_editors() {
2 // Get the current user object
3 $current_user = wp_get_current_user();
4 
5 // Check if the user has the Editor role
6 if (in_array('editor', $current_user->roles)) {
7 // Hide the toolbar option with CSS
8 echo '<style>.show-admin-bar { display: none; }</style>';
9 }
10}
11add_action('admin_head-profile.php', 'hide_toolbar_option_for_editors');

0

Related Snippets

Please see some snippets below related to this snippet..

WordPress Admin

AI Verified

1

Disable Wordpress Admin Bar

Added: 2 years ago

Last Updated: 1 year ago

The WordPress Admin Bar provides handy links to several key functions such as the ability to add new posts and pages, etc. However, if you find no use for it and wish to remove it just activate this s...

WordPress Admin

AI Verified

1

Hide WP Admin Bar For Non-Admins

Added: 1 year ago

Last Updated: 1 year ago

Hide WP Admin Bar For Non-Admins

WordPress Admin

AI Verified

1

Randomize a Post Publish Date in the Classic Editor [SnipSnip.pro]

Added: 10 months ago

Last Updated: 10 months ago

<p>Randomize a Post Publish Date in the Classic Editor. Choose between the past 1, 3, 6, 12 months... or customize it to other options. Works in the Classic Editor only for now. <a href="https://snips...

Other Snippets in this Codevault

These are some popular snippets from this users codevault..

WordPress Admin

AI Verified

0

Hiding "Show Toolbar when viewing site" checkbox on profile page for specific user roles

Added: 1 year ago

Last Updated: 1 year ago

Have a user role that you want to hide "Show Toolbar when viewing site" checkbox on the profile page? This will remove the checkbox on specific user roles so Admins can control who has the admin toolb...

WooCommerce

AI Verified

0

WooCommerce Product Page - Category Dropdown

Added: 1 year ago

Last Updated: 1 year ago

In the Product page on the backend, the woocommerce category search filter will stop being a dropdown menu when you exceed 100 categories. It turns into an autofill search field. This snippet stops th...