Möchten Sie die WordPress-Adminleiste für alle Benutzer außer Administratoren deaktivieren?
Standardmäßig können Sie die WordPress-Verwaltungsleiste für einzelne Benutzer einfach deaktivieren. Dies kann jedoch einige Zeit dauern, wenn Sie viele registrierte Benutzer auf Ihrer Website haben.
In diesem Artikel zeigen wir Ihnen, wie Sie die WordPress-Adminleiste ganz einfach für alle Benutzer außer Administratoren deaktivieren können.
Was ist die WordPress Admin Bar?
Standardmäßig zeigt WordPress für alle angemeldeten Benutzer eine Verwaltungsleiste am oberen Rand des Bildschirms an. Wenn Sie bei Ihrem Konto angemeldet sind, können Sie diese Symbolleiste im WordPress-Verwaltungsbereich und auf allen anderen Seiten sehen.
Die WordPress-Admin-Symbolleiste enthält nützliche Verknüpfungen zu verschiedenen Backend-Bereichen von WordPress, und diese Verknüpfungen ändern sich je nach der Rolle und den Berechtigungen eines Benutzers in WordPress.
Die Verwaltungsleiste kann jedoch ablenken, wenn Sie sich das Frontend Ihrer Website ansehen.
Es kann auch das Design Ihrer Website und die Benutzerfreundlichkeit beeinträchtigen. Dies kann ein Problem sein, wenn Sie eine WordPress-Website für einen Dritten erstellen oder verwalten, da dieser dadurch nicht mehr sehen kann, wie seine Website wirklich aussieht.
Glücklicherweise gibt es mehrere Möglichkeiten, die Admin-Leiste für alle Benutzer außer Administratoren zu deaktivieren. Verwenden Sie einfach die unten stehenden Links, um zu der gewünschten Methode zu gelangen:
Video-Anleitung
Wenn Sie eine schriftliche Anleitung bevorzugen, dann lesen Sie einfach weiter.
Methode 1: Deaktivieren Sie die WordPress-Adminleiste für einzelne Benutzer
Sie können die Admin-Leiste für bestimmte Benutzer deaktivieren, indem Sie einfach deren Benutzerprofil bearbeiten. Dies ist eine schnelle und einfache Methode, wenn Sie die Leiste nur für eine kleine Anzahl von Personen entfernen möchten. Wenn Sie jedoch eine Mitgliederseite mit vielen Nutzern betreiben, empfehlen wir Ihnen, eine andere Methode zu wählen.
Um die Admin-Leiste manuell zu entfernen, gehen Sie einfach auf die Seite Benutzer “ Alle Benutzer im WordPress-Administrations-Dashboard. Fahren Sie dann mit der Maus über den Benutzer, der die Admin-Leiste nicht benötigt, und klicken Sie auf „Bearbeiten“, wenn sie erscheint.
Dadurch wird das Profil dieses Benutzers geöffnet.
Deaktivieren Sie hier das Kontrollkästchen neben der Option „Symbolleiste beim Anzeigen der Website anzeigen“.
Scrollen Sie dann zum unteren Ende des Bildschirms und klicken Sie auf „Benutzer aktualisieren“, um Ihre Änderungen zu speichern. Dadurch wird die Admin-Leiste nur für diese bestimmte Person deaktiviert.
Um die Symbolleiste für weitere Benutzer auszublenden, gehen Sie einfach wie oben beschrieben vor.
Methode 2: Deaktivieren der Admin-Leiste für alle Benutzer außer Admins (empfohlen)
Wenn Sie die Admin-Leiste für viele verschiedene Personen ausblenden müssen, wäre es sehr zeit- und arbeitsaufwändig, die Einstellungen für jeden einzelnen Benutzer manuell zu ändern.
Aus diesem Grund empfehlen wir, die Admin-Leiste zu deaktivieren, indem Sie einen Code in die Datei functions.php einfügen, bei der es sich um eine WordPress-Theme-Datei handelt. Wenn Sie dies noch nicht getan haben, lesen Sie unsere Anleitung zum Kopieren und Einfügen von Codeschnipseln in WordPress.
In einigen Anleitungen wird Ihnen empfohlen, die Themadateien manuell zu bearbeiten, was jedoch zu häufigen WordPress-Fehlern führen und Ihre Website sogar komplett zerstören kann.
Aus diesem Grund empfehlen wir die Verwendung von WPCode. Es ist das beste Code-Snippet-Plugin und macht es einfach, benutzerdefinierten Code in WordPress hinzuzufügen, ohne Ihre Website zu gefährden.
Zunächst müssen Sie das kostenlose WPCode-Plugin installieren und aktivieren. Weitere Informationen finden Sie in unserer Schritt-für-Schritt-Anleitung zur Installation eines WordPress-Plugins.
Sobald das Plugin aktiviert ist, gehen Sie zu Code Snippets “ Snippet hinzufügen.
Hier sehen Sie alle vorgefertigten Snippets, die Sie zu Ihrer Website hinzufügen können. Dazu gehört ein Snippet, mit dem Sie Kommentare vollständig deaktivieren, Dateitypen hochladen können, die WordPress normalerweise nicht unterstützt, Seiten mit Anhängen deaktivieren und vieles mehr.
Auf dem nächsten Bildschirm müssen Sie mit der Maus über die Option „Benutzerdefinierten Code hinzufügen (neues Snippet)“ fahren und auf die Schaltfläche „Snippet verwenden“ klicken, wenn diese erscheint.
Geben Sie auf dem nächsten Bildschirm einen Titel für das Code-Snippet ein. Dieser dient nur als Referenz, Sie können also alles verwenden, was Sie wollen.
Öffnen Sie dann das Dropdown-Menü „Codetyp“ und wählen Sie „PHP Snippet“.
Fügen Sie dann einfach den folgenden Code in den Editor ein:
add_action('after_setup_theme', 'remove_admin_bar');
function remove_admin_bar() {
if (!current_user_can('administrator') && !is_admin()) {
show_admin_bar(false);
}
}
Dieser Code identifiziert alle Nicht-Admin-Benutzer, die derzeit nicht das Admin-Dashboard sehen. Für diese Benutzer wird die WordPress-Adminleiste deaktiviert.
Blättern Sie dann auf der Seite nach unten zum Abschnitt „Einfügen“. Hier können Sie die Standardmethode „Automatisches Einfügen“ beibehalten, um sicherzustellen, dass der Code überall ausgeführt wird.
Scrollen Sie schließlich an den oberen Rand des Bildschirms und klicken Sie auf den Schieberegler „Inaktiv“, so dass er „Aktiv“ anzeigt.
Klicken Sie dann einfach auf die Schaltfläche „Snippet speichern“ oder „Aktualisieren“, um das Code-Snippet zu aktivieren.
Das war’s! Vergessen Sie nicht, Ihre WordPress-Website zu überprüfen, um sicherzustellen, dass alles einwandfrei funktioniert.
Methode 3: Deaktivieren der WordPress-Adminleiste für alle Benutzer außer Admins (kein Code erforderlich)
Wenn Sie Ihrer Website keinen Code hinzufügen möchten, können Sie die Admin-Leiste mithilfe eines Plugins ausblenden. Mit dem Plugin Hide Admin Bar Based on User Roles können Sie die Symbolleiste je nach Benutzerrolle ausblenden. Dies ist also eine gute Wahl, wenn Sie die Leiste für alle Mitglieder, WooCommerce-Kunden oder eine andere Benutzerrolle deaktivieren möchten.
Zunächst müssen Sie das Plugin Hide Admin Bar Based on User Roles installieren und aktivieren. Weitere Details finden Sie in unserer Schritt-für-Schritt-Anleitung für die Installation eines WordPress-Plugins.
Nach der Aktivierung müssen Sie die Seite Einstellungen “ Einstellungen für die Adminleiste ausblenden aufrufen. Aktivieren Sie hier die Kästchen neben den Benutzerrollen, für die Sie die Admin-Leiste deaktivieren möchten.
Klicken Sie dann einfach auf „Änderungen speichern“, um Ihre Einstellungen zu speichern.
Methode 4: Deaktivieren der Admin-Leiste für alle Benutzer (einschließlich Admins)
Möchten Sie die Verwaltungsleiste für alle Benutzer, einschließlich der Website-Administratoren, deaktivieren?
Sie können dies tun, indem Sie einen Code hinzufügen, der die Verwaltungsleiste für jeden deaktiviert, der die öffentlichen Seiten Ihrer Website betrachtet. Dies bedeutet, dass die Verwaltungsleiste nur angezeigt wird, wenn Sie sich im WordPress-Dashboard-Bereich befinden.
Um die Sache zu vereinfachen, hat WPCode genau den Code-Schnipsel, den Sie brauchen, in seiner integrierten Snippet-Bibliothek. Gehen Sie einfach zu Code Snippets „ Bibliothek.
Suchen Sie hier nach ‚Disable The WP Admin Bar‘.
Wenn das richtige Snippet angezeigt wird, klicken Sie einfach auf die Schaltfläche „Snippet verwenden“.
Das Plugin fügt den Code automatisch zu Ihrer Website hinzu, gibt dem Code einen beschreibenden Titel, wählt die richtige Einfügemethode und fügt sogar Tags hinzu, damit Sie das Snippet identifizieren können.
So sieht der Code aus:
/* Disable WordPress Admin Bar for all users */
add_filter( 'show_admin_bar', '__return_false' );
Jetzt müssen Sie nur noch den Schalter von „Inaktiv“ auf „Aktiv“ umlegen und dann auf „Aktualisieren“ klicken.
Wenn Sie nun das Frontend Ihrer Website aufrufen, während Sie in Ihrem WordPress-Konto angemeldet sind, wird die Verwaltungsleiste ausgeblendet.
Wir hoffen, dass dieser Artikel Ihnen geholfen hat zu erfahren, wie Sie die WordPress-Adminleiste für alle Benutzer außer Administratoren deaktivieren können. Vielleicht interessieren Sie sich auch für unseren ultimativen WordPress-Sicherheitsleitfaden und unseren Vergleich der besten WordPress-Seitenerstellungsprogramme für die Erstellung benutzerdefinierter Seitenlayouts ohne Code.
Wenn Ihnen dieser Artikel gefallen hat, dann abonnieren Sie bitte unseren YouTube-Kanal für WordPress-Videotutorials. Sie können uns auch auf Twitter und Facebook finden.
Syed Balkhi says
Hey WPBeginner readers,
Did you know you can win exciting prizes by commenting on WPBeginner?
Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
You can get more details about the contest from here.
Start sharing your thoughts below to stand a chance to win!
Destiny Boy says
This was very simple ans straight forward, it helped me
ronald osoo says
This code has bug , its working but not bullet proof . The normal user can by -pass this and get access to the user admin like panel at the top by just adding wp-admin/ to the url like trying to login
Math says
I agree, direct access to wp-admin/profile.php is making this useless.
Steve says
A lot of websites not only from wordpress have the same option. You can acces to the admin-login page of any website just writing example.com/admin : Thats normal. I find it’s look really good without the adminbar.
Alex S says
Hello,
I wish your syntax highlighter was better. Tried to copy the code and got the numbers starting at 2. I don’t need your numbers, just the good code. I would use this site a lot more if this was not the case.
Thanks.
WPBeginner Support says
You can also click on the little button on top right corner of the code snippet. It will open the raw code in a popup, which is much easier to copy.
Admin
stefano says
It works well, but the bar remains for visitors, who have not made the LOGIN
Jenn says
This plugin was working great and I was using Theme My Login. When I deactivated that plugin it is not not functioning as before… I see the admin bar for all users. Any suggestions?
Jenn says
Sorry I meant to say this ‚code‘ was working great. I created a site-specific plugin as well and everything was working great. But after deactivating Theme My Login, not it seems to not have any effect and I see the admin bar on all users.
Suggestions?
Jenn says
I just tried adding in the code for all users: show_admin_bar(false); and I can still see the admin bar.
Alexander Pardo says
Thank you very much ! A very simple and clean solution.
Jason A. Churchill says
I’m not well-read in editing the functions.php file. My first two attempts resulted in syntax error messages.
Where exactly should I place this code in the functions.php file?
WPBeginner Support says
At the end. If your functions.php file ends with ?> then you need to paste the code just before it.
Admin
Terry Hale says
Thanks so much for this! No plugins, nice, clean, simple.
WPBeginner Staff says
WordPress admin bar is displayed only for logged in users.
Bhris says
Great straight-to-the-point tutorial.
Is there a version of the code that will block all non-users. That is, visitors to the site won’t see the bar, while all logged-in users would?
Shashi says
I was trying to do what what was mentioned in the article and it did not work. I used the following instead which did the trick from me:
if ( ! current_user_can( ‚manage_options‘ ) ) {
show_admin_bar( false );
}
The above was mentioned in the wordpress codex: http://codex.wordpress.org/Function_Reference/show_admin_bar
vipin says
Thanks a lot its really cool…………
Karen says
Neither worked for me. I copied the numbers with the text as I did not know that I could
click on the button on top right corner of the code snippet and copy the raw code. I removed the numbers, but overlooked the seven. I had to change the file entry in via my file manager as I could no longer edit the functions.php. So after a scare and a bit of back and forth I removed the number and the admin bar is still there. I also tried your code Shashi, but it’s not working either.
I have tried every plugin under the sun and nothing will remove the bar.
kim04099 says
Thank You!!
Che Boielle says
Fastest fix to an odd issue I’ve ever found and implemented. Great explanation simple to follow instructions. Thanks guys, will be book marking your site.
Manthan says
Thanks, Its the easiest way found..!!!
Ryan McGovern says
Thanks for the code snippet!
Anup says
Why not simply do this for any specific user.
Jack says
It would be hard to do this if you have many users.
Róger Marroni says
Great job man!
thank you very much!
Mega says
I tried and my site is black.
Ryan S says
the first step works fine, it is something in your end, maybe while implementing the code
Etienne says
Perfect piece of code… Thanks a lot!
Cheers
Nathan Jansen says
Use this if you want this only for a certain role
function remove_admin_bar() {
$user = wp_get_current_user();
if (in_array(’subscriber‘, $user->roles)) {
show_admin_bar(false);
}
}
meef says
Godbless You. Answers to my problem always come from you post.
Thanks
Prem says
Finally I got the answers Thank you
Paw Pet Directory says
I used this on my directory for my customers but the bar will not go away for them. I am using 3.8 with AppThemes Vantage Theme (Latest)
Cory says
This is one of those things that, because it’s such a small customization, I’d hate to use a plugin for. So being able to throw this short piece of code into my child theme’s functions.php made me super happy. Thanks so much far sharing! Works like a charm.
Raman says
Thanks for posting it was useful.
Naveen says
I have added this code it is working fine, but if a user takes meta there is an option yo view the admin, if i click on this the admin page can see, how to avoid this, i dont want to give admin panel to the users, a user can edit the url and give /wp-admin also he can see the admin, i dont want both what will do for this?
Subodh says
Admin bar is hidden but now how can a user log out?
I am using bbpress forum and a plugin for users to log in via their Facebook account to join forum. But find no option for logging out.
WPBeginner Support says
A link to the logout or login can be provided into sidebar or menus. WordPress comes with a default widget called meta which has login/logout link. Or you can add one to your site’s navigation menus. See our guide on how to show different menus to logged in users
Admin
Loralee says
Thanks for the great tutorial. I thought it didn’t work – and then silly me I hadn’t followed the last step to activate my new plugin!! Thanks so much for this! So much better than installing multiple new plugins.
vikas says
Thanks mate….u were really helpful…
tc
Rajat says
Thx syed it just worked perfectly
Bongo says
Thanks for this, it helped me a lot
Andy Wagstaff says
I have an area of my site that requires log-in registration.
I have made the admin bar „autohide“ by requiring a plug-in, I don’t want to entirely disable it, as I need the abiity to change password, but is there any way of removing items from the bar for users? I don’t want the site name,WP logo or the theme extensions options on the left hand side.
Is this possible? I am sure it is, but I can’t work it out!!
Ta!! Really handy site by the way
Andy
Rajiv says
Hi,
I want to disable BP Admin Bar for Logged Out Users.
Please help.
Ken Shoufer says
Hello,
Your code worked fine when I tried it locally on my computer, but when I tried it on a fresh WordPress install on my host server it would not let me log out. When I tried to log out, the address showing was „http://www.ken-shoufer.com/wordpress1/wp-login.php?action=logout&_wpnonce=9e7f51a307“.
I’m not sure what is wrong.
Editorial Staff says
That’s weird because we have it running on our live site.
Admin
Adrian says
Thanks!
Fabio Santos says
You can use this nice plugin instead: http://wordpress.org/plugins/global-admin-bar-hide-or-remove/
Nate says
i am trying to disable the W logo on the top left, the „My Sites“ menu and the dashboard link on a buddypress multisite install. I want to keep the right side functional which shows the links to their buddypress profile settings. How can I achieve this?
Tanner Moushey says
To avoid the blank space where the admin bar was, call the function in the „after_setup_theme“ action instead of „init“.
Cristian O. Balan says
Really perfect, thanks a lot!
Will says
Thank you so much! This worked perfectly and resolved several hours of head-scratching.
Cristian B. says
Really nice code. Are here also a fix to the blank bar that many here complains?
David says
Hi,
To avoid the blank, just instead of :
add_action(‚init‘, ‚remove_admin_bar‘);
use:
add_action(‚after_setup_theme‘, ‚remove_admin_bar‘);
Cristian O. Balan says
Thanks a lot man!
niki says
Fantastic! Except I also have the blank space visible where the admin bar would be. Does anyone have a fix for this?
Marlita Hill says
Hello. Thank you for this. How would I write the code if I only want the bar accessible to admin and contributors? I still do not want the contributors to have admin access to my backend.
Steve says
Well… it removes the admin bar but it´s still occupying the space meaning there´s too much space up there now. I´m not sure it´s supposed to be that way?
Adam says
worked …
Thanks a lot
Nick Cokas says
Add the code and worked perfect. However, the user still sees a white space above were the toolbar existed before. Any ideas to remove that.
Thanks
Toby Couchman says
Did you use a plugin to place all the necessary user stuff on the frontend?
My team recently built a site with similar requirements and I’d love to compare the processes.
Cheers
Toby
Mark Coleman says
Do not pass a role name to current_user_can(), as this is not guaranteed to work correctly. from
http://codex.wordpress.org/Function_Reference/current_user_can
just FYI
Editorial Staff says
Agreed. Just updated the code to make it into a function, and then adding it in via action.
Admin
Sally says
Excellent post thanks so much!
Took me under a minute and the bar was gone… forever… truly grateful.
Sally x
Corey Freeman says
Thanks to this I have one less plugin bloating my site. Woo!
Delton Childs says
This is an awesome post. short, to the point and contained a useful snippet! Thank you so much!
I’m using the S2Member plugin also, I was very concerned about compatibility issues with plugin based solutions because of the various s2Membership Levels. This solutions is working wonderfully for me.
Thanks Again!
James Davis says
Hi Guys,
Just found this bit of code and it worked perfect for my site…
Thanks so much
Cheers
James
AKA The Fitness Blogger
glueckpress says
Nice. For Superadmins in a Multisite install it would read like if(!current_user_can(‚manage_network‘)) //etc.