Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

Deaktivieren der WordPress-Adminleiste für alle Benutzer außer Administratoren

Hinweis der Redaktion: Wir erhalten eine Provision für Partnerlinks auf WPBeginner. Die Provisionen haben keinen Einfluss auf die Meinung oder Bewertung unserer Redakteure. Erfahre mehr über Redaktioneller Prozess.

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.

How to disable WordPress Admin Bar for All Users except administrators

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.

The WordPress admin bar

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

Subscribe to WPBeginner

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.

How to edit a user's profile in WordPress

Dadurch wird das Profil dieses Benutzers geöffnet.

Deaktivieren Sie hier das Kontrollkästchen neben der Option „Symbolleiste beim Anzeigen der Website anzeigen“.

How to hide the admin toolbar for non-admin users

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.

Hiding the admin toolbar using WPCode

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.

Adding custom code to your WordPress website with WPCode

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“.

Adding a PHP snippet to WordPress using WPCode

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.

Automatically inserting code into a WordPress website

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.

Publishing a custom code snippet to WordPress

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.

Hiding the admin toolbar for specific user roles

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.

The WPCode code snippet plugin for WordPress

Suchen Sie hier nach ‚Disable The WP Admin Bar‘.

Wenn das richtige Snippet angezeigt wird, klicken Sie einfach auf die Schaltfläche „Snippet verwenden“.

The ready-made Disable The WP Admin Bar code snippet

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.

Adding custom code to WordPress

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.

Offenlegung: Unsere Inhalte werden von unseren Lesern unterstützt. Das bedeutet, dass wir möglicherweise eine Provision verdienen, wenn Sie auf einige unserer Links klicken. Mehr dazu erfahren Sie unter Wie WPBeginner finanziert wird , warum das wichtig ist und wie Sie uns unterstützen können. Hier finden Sie unseren redaktionellen Prozess .

Das ultimative WordPress Toolkit

Erhalte KOSTENLOSEN Zugang zu unserem Toolkit - eine Sammlung von WordPress-bezogenen Produkten und Ressourcen, die jeder Profi haben sollte!

Reader Interactions

162 KommentareEine Antwort hinterlassen

  1. 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!

  2. Moinuddin Waheed says

    This is very needed to hide the admin bar to all the user’s except the administrator.
    I have thought of doing this multiple times over specially when I was running news website and I had many authors and contributors.
    Showing them admin bar is not only unnecessary but annoying too.
    Really appreciate for the steps to get rid of this admin bar and keep it for only the administrator.

  3. Amos Showole says

    Wow… This is great, you solved an issue I faced with on one of my WordPress website that BuddyPress was installed on….

  4. Paul says

    Using the after_setup_theme hook doesn’t always work. Try this instead:

    function remove_admin_bar( $value ) {
    return ( current_user_can( ‚administrator‘ ) ) ? $value : false;
    }
    add_filter( ’show_admin_bar‘ , ‚remove_admin_bar‘);

  5. Joey says

    What would be the code if I want to add Editor and Admin to show the Admin bar..

    if (!current_user_can(‚administrator‘) && !is_admin())…

    if (!current_user_can(‚editor‘) && !is_editor())…

    would it be if (!current_user_can(‚administrator‘) && !is_admin() || !current_user_can(‚editor‘) && !is_editor())

    would this work?

    • WPBeginner Support says

      For what you are wanting, you would want to remove: && !is_editor()

      Then it should work how you are wanting.

      Admin

  6. Basia says

    Hi,
    I hide admin bar with plugin You recommend, but when subscriber log in he can still click on „view my profile“ and see wp dashboard. Can I disable that?

    • WPBeginner Support says

      If method 3 is not working for you, we would recommend trying one of the other methods to test.

      Admin

    • WPBeginner Support says

      You may want to try clearing your cache for the most common reason for the change not being visible.

      Admin

  7. Paul says

    What exactly does this disable? I still see an admin bar and I have access to menu options when I go to example.com/wp-admin when i’m logged into a subscriber account.

    • WPBeginner Support says

      You would want to ensure the code was properly added for the most likely cause of the admin bar not being hidden otherwise, you could also have a plugin that would be overriding this code.

      Admin

  8. Marc Korden says

    Cannot add the admin code in my theme:

    Communication with the site not possible to check for errors, the PHP adjustment has been reversed. The PHP file change needs to be changed in another way, for example using SFTP.

  9. Agha Mubasher says

    Hello there…!
    First of all i simply love the work wpbeginner, as you always bring forward the simplest solutions to our wordpress issues. Your website and Youtube channel has always been helpful for me. Thumbs Up for that.. :)

    I had issue with hiding the admin bar for the subscribers only. Now after applying your code in the function.php it is hidden for my editors also.
    Is there any way that my editors also can see the admin bar and only it should be hidden from the subscribers..!!

    • WPBeginner Support says

      For that, you would need to target another permission that your editor has instead of what we are targeting such as edit_others_posts

      Admin

  10. Jesaja says

    On my website it says:

    „Unable to communicate back with site to check for fatal errors, so the PHP change was reverted. You will need to upload your PHP file change by some other means, such as by using SFTP.“

    What to do now?

  11. Jim says

    Can this code be altered to allow the WordPress Admin bar for Admins AND moderators, but hide it for everyone else?

    Thanks!

  12. Andreas says

    If a user knows the URL structure of WordPress he can easily browser to /wp-admin/ and there the admin toolbar will be visible. Also, the easiest way is to deactivate it in the user setting if you have a small number of users.

  13. Adam Pressman says

    Doesn’t work. Well, to be fair, works when you first use it but then something happens and it doesn’t anymore. nothing is overwriting the functions.php and the code is there but usually after the first login, logout cycle a subsequent login will see the admin bar return.

  14. Cesar says

    I have created a social media site using several plugins and everything works fine but for one issue. Pages are successfully restricted and redirected (Buddypress pages, blogs, etc) for non-logged in users.

    However the main issue I am having is that non-logged in users can still have access to blog posts and user profile pages via widgets placed on side bar and footer and I cannot seem to find a solution anywhere.

    Any ideas on the matter, plugins or code that I can insert in the child theme?

    I have been looking for a solution for over a day and all there is there is how to restrict pages and partial content but nothing works on the widget links, they keep going thru the restrictions in place.

    Thanks

    • WPBeginner Support says

      Hey Cesar,

      There are several widgets and plugins that allow you to hide widgets from non-logged in users. However, if non-logged in users know the URL, then they would still be able to access those URLs directly. You need to review your plugin settings and see if you can find the option to hide profile pages from non-logged in users.

      Admin

  15. Shabz says

    This code or several others that I tried from the comments isn’t working. I’m trying to remove that dumb silver/black wordpress tab above my menu that shows up for all of my website’s users. How do I remove that? Please help :)

    • Jack Hernandez says

      As mentioned in the article, you included a way for users to edit their profiles through the front end without the admin bar. How did you accomplish that.
      Thanks

  16. Chouchouda says

    Hello, some issue , i have done everything but can’t hide toolbar for owner user in frontend , but can do this for admin user , incredible.
    I’m using search& go theme wordpress , Thank for your help.

  17. Alex says

    Hello,

    Code needs a little updating. This is the code I would use to redirect by role.

    /*Hide admin bar for certain roles*/
    function hide_admin_bar() {
    if(is_user_logged_in() ) {
    $current_user = wp_get_current_user();
    if ( in_array( ’subscriber‘, (array) $current_user->roles ) ) {
    add_filter(’show_admin_bar‘, ‚__return_false‘);
    }
    }
    }

    Hope this helps.

    • Brandon says

      Thanks for this updated code, Alex. Simple and works great.

      Put it in child theme functions.php and forget about it. :)

    • Yuki Zain says

      Thanks, Alex but I’m editing a bit

      /*Hide admin bar for certain roles*/
      if(is_user_logged_in() ) {
      $current_user = wp_get_current_user();
      if ( in_array( ’subscriber‘, (array) $current_user->roles ) ) {
      add_filter(’show_admin_bar‘, ‚__return_false‘);
      }
      }

    • randalf says

      Very nice :) but what do I do if I have two roles as a result of bbpress plugin.. That is registered users have the subscriber role in whole site and participant role in bbpress.
      Please help

  18. Scott says

    Hi,

    I inserted your code to remove the Admin bar from my membership site. Unfortunately it also removed it from me, the Admin (even thought I used your first option above). I am using the Tesseract Pro theme. Do you have any suggestions? Thanks

  19. Inder Singh says

    Dear Sir,
    I have 2 admin user and i want to show admin bar for first user and remove admin bar for second user in wordpress.
    How can i do it.

    Thanks for support.

  20. SG says

    I tried using this and I got that code Parse error: syntax error, unexpected ‚}‘ in /home/content/76/10323476/html/wp-content/themes/digitalscience-apex/functions.php on line 168 and I can’t get my site back even after deleting it.

  21. Krzysiek Dróżdż says

    Well, I wouldn’t use current_user_can for that… Codex says, that you can use it for role checking, but in the code you can find:

    * While checking against particular roles in place of a capability is supported
    * in part, this practice is discouraged as it may produce unreliable results.

    So… Much better and secure way to do this is:

    $user = wp_get_current_user();
    if ( ! in_array( ‚administrator‘, (array) $user->roles ) ) {

    }

  22. Lyndal Sirit says

    i used it and it crashed my site, trying desperately to fix it now, i took the code back out and updated but I am getting an Error: Parse error: syntax error, unexpected ‚3‘ (T_LNUMBER) in /home/lyndalspirit/public_html/wp-content/themes/primer/functions.php on line 516

    • WPBeginner Support says

      Hi Lyndal,

      Some times when users copy code from websites like WPBeginner, they also copy the line numbers which they are not supposed to copy. When they paste this code in their functions.php file it causes an error.

      You need to connect to your site using an FTP client. Locate your functions.php go to the code you added and remove it. Save your changes.

      Admin

  23. Chris says

    This worked fine for me as-is, i stripped out the line numbers and stuck it at the end of my theme functions.php – instant success. thanks so much.

    • WPBeginner Support says

      Login to your WordPress admin area using an Administrator account. Click on the Users menu item from the admin sidebar. This will show you a list of users registered on your WordPress site. Locate the user you wish to remove. Click on the Delete link below the username of the person you want to remove.

      Admin

    • JGUISS says

      JGUISS

      Didn’t worked for me…
      It’s worked with that : add_filter(‘show_admin_bar’, ‘__return_false’);

      how does the code look like with this added I’m not familiar enough with php to add it in

  24. The Little Binger says

    Hello!

    Thank you so much for being such a great help! I installed this code on the function file but it does not seem to work. I loaded my page on a different browser but the Log In bar is still there. Why is that? I also read your article about adding codes to the PHP file.

    I hope you could help me out on this. Thanks!!

  25. Vic says

    Hi! First of all, thanks for these codes, it’s very helpful, provided I considered myself not a first timer anymore who remember to add after the codes!
    I locked myself at the first time trying to add the php coding in my functions.php file as well, thanks to the „expert“ web developer who didn’t show the full set of codes for a function. And thanks to your „what to do when you are locked out of WordPress admin area“ site, I found out why I was locked out in the first place! But it took me a downtime of 3 days to figure out how to use the FTP, which at the end failed to function, but my webhost Helpdesk suggested me to use the File Manager in their Control Panel instead! Luckily it works! Lessons learnt the hard way, but worth it.. :P
    Just a kind suggestion, since this site was supposed meant for „WPBeginner“, I think all of the WP users beginner would appreciate if full set of codes are provided, rather than every other person „shouting“ in the comment section that „The codes didn’t work, and locked me out“, and then you have to advise them to read a full length of another tutorial how to unlock their website, even though yes, you wish to teach us „How to fish“ instead of „Fish for us“ every time!
    Anyway, thanks again and appreciate your efforts here in guiding us, the WP Beginners! :)

    • WPBeginner Support says

      Thanks for the feedback. We try to make code easy to paste and use. However, usually there is already code in your functions.php file, which may affect the end result. We are glad you found your way out. :)

      Admin

Eine Antwort hinterlassen

Danke, dass du einen Kommentar hinterlassen möchtest. Bitte beachte, dass alle Kommentare nach unseren kommentarpolitik moderiert werden und deine E-Mail-Adresse NICHT veröffentlicht wird. Bitte verwende KEINE Schlüsselwörter im Namensfeld. Lass uns ein persönliches und sinnvolles Gespräch führen.