0

I don't want to unregister_widget() the widget on the screen, rather, just hide them for admins. Any ideas? I tried: remove_meta_box('widget-id', 'widgets'); but I couldn't figure out the second argument - the screen/page that the widget is displaying on because I can't find the id of the widgets screen

https://developer.wordpress.org/reference/functions/remove_meta_box/

1 Answer 1

0

This should already be the case, non-administrators do not have access to the 'Appearance' menu by default.

Here is a list of each role and their capabilities: https://codex.wordpress.org/Roles_and_Capabilities


Okay so if you want to hide it for everyone, remove_meta_box() won't work because it's not a meta box as far as I can tell from looking at the source.

So alternatively what you could do is:

  1. Remove the menu item using remove_submenu_page('themes.php','widgets.php'); however the page would still be accessible to admins if they just type in the correct url.
  2. Use css to hide the widget. Use admin_enqueue_scripts to set that up.
4
  • Fair enough. I want it to be hidden for admins as well
    – Tanner
    Commented Mar 30, 2017 at 15:25
  • Okay updated my answer
    – ngearing
    Commented Mar 30, 2017 at 20:20
  • ah that's a good idea to use CSS.. I was not thinking hah. Although is this just a workaround?
    – Tanner
    Commented Mar 30, 2017 at 20:56
  • Yeah a bit of a workaround, this situation is a bit odd. Normally if you don't want someone to have access to widgets, you wouldn't make them an admin.
    – ngearing
    Commented Mar 30, 2017 at 22:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.