I am using my functions.php
to add a custom meta box on my posts page in the WordPress Admin Area. However, I need to make it so its only visible to admins, and not editors, contributors, etc.
What would I do to make it visible to admins only?
I am using my functions.php
to add a custom meta box on my posts page in the WordPress Admin Area. However, I need to make it so its only visible to admins, and not editors, contributors, etc.
What would I do to make it visible to admins only?
You must be logged in to post a comment.
This snippet works for custom taxonomies. It removes / hides a custom taxonomy meta box for all non-admins, assuming no other role has the
update_core
capability. Similar, but opposite of the answer by @johannes-pilleNote that the third argument of
remove_meta_box
may differ, see https://codex.wordpress.org/Function_Reference/remove_meta_box