restricted-site-access icon indicating copy to clipboard operation
restricted-site-access copied to clipboard

Add a setting to RSA to hide the admin bar for subscriber users on the FE

Open fabiankaegy opened this issue 7 months ago • 4 comments

This is a common need for previewing sites to low access users.

fabiankaegy avatar May 08 '25 16:05 fabiankaegy

CC: @jeffpaul this came up for us on the fdc project. Might be a nice little enhancement here

fabiankaegy avatar May 08 '25 16:05 fabiankaegy

@fabiankaegy given some sites have other various roles created, do you think this should be something like "display the admin bar for these user roles"? Maybe even targeting specific capabilities (perhaps too technical for most site owners)?

jeffpaul avatar May 08 '25 16:05 jeffpaul

@jeffpaul yeah I think targeting edit-posts should be a good default. Maybe with a filter?

fabiankaegy avatar May 08 '25 18:05 fabiankaegy

And just because it caused issues for us:

We need to make sure that the --wp--admin-bar--height variable is also nulled out / removed. This didn't work for us in our naive implementation

fabiankaegy avatar May 08 '25 18:05 fabiankaegy

@jeffpaul @fabiankaegy

We need to make sure that the --wp--admin-bar--height variable is also nulled out / removed. This didn't work for us in our naive implementation

I don't think we need this, because show_admin_bar filter will take care of it. as you can see it in the method - is_admin_bar_showing() - that contains this filter.

The class - class-wp-admin-bar.php - won't load if that filter return false, as it is shown here in this method: _wp_admin_bar_init().

That class handles the logic for enqueueing the CSS/JS related to the admin bar functionality: https://github.com/WordPress/WordPress/blob/master/wp-includes/class-wp-admin-bar.php#L72-L73

sanketio avatar Aug 06 '25 14:08 sanketio