Jump to content
Martijn Geerts

user role added as class to the body of admin

Recommended Posts

Sometimes I wish to visually hide certain aspects of the admin when the logged-in user is not super user.

When <body class='the-current-user-role'> is added, it's easy to just "display: none" for some elements you want to hide.

Share this post


Link to post
Share on other sites

This would be pretty easy to add to any admin theme:

<body class="<?php foreach($user->roles as $role) echo "role_" . $role->name . " "; ?>">

But whether it's advisable is another question. If you don't want the user to have access to something, it's best that the logic of the page knows not to even display or accept input to it. Otherwise it's a potential security hole. Though for non-security related display adjustments, it seems like a fine way to go. 

Share this post


Link to post
Share on other sites

For me it's just to the form-builder and custom settings pages that I want to hide just for normal editors. The Way you describe it now is the way I do it now.

The problem with me is that I update to often & sometimes forget or just overwrite previously set things I changed.

Share this post


Link to post
Share on other sites

you.can  move admins themed to 

/site/templates-admin/ 

no mas.worry on upgraded

  • Like 2

Share this post


Link to post
Share on other sites

I'm happy to add this to the default admin theme too. 

  • Like 4

Share this post


Link to post
Share on other sites

Don't think this made it into the default admin theme, so +1 for this.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...