Hiding the widget meta box in the Appearance->Widget screen

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.

tech