PHP snippet · Admin & Dashboard
Hide the admin bar for non-admins
Hides the front-end admin bar for everyone below administrator, so customers and members see your design instead of a black bar over it.
About this php snippet
On any site with customer, member, or subscriber accounts, the admin bar sits over your design for people who have nothing to do with running it. They did not ask for it, and it tells them nothing they can use.
It also pushes the whole page down by 32 pixels, which quietly breaks sticky headers and full-height hero sections for logged-in visitors only. That is why it usually arrives as a report of an intermittent layout bug that nobody else can reproduce.
What it does
- Hides the front-end admin bar for any user without the chosen capability
- Keeps it for administrators
- One capability value at the top of the snippet if you want the line drawn somewhere else
Good to know
- Out of the box, the line is administrator, so everyone below it loses the bar
- Switch the capability to the one editors hold, and authors and editors keep the bar too
- wp-admin is untouched. This is the front-end bar only, so anyone who belongs in the dashboard still gets there normally.
- Logged-out visitors never saw the bar in the first place, so nothing changes for them



