Created
June 1, 2018 12:05
-
-
Save jb510/acf5260a3d44ebdfda8e511e77b39ade to your computer and use it in GitHub Desktop.
Hide metaboxes by user role
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //* Hide Extra Metaboxes from certian user roles | |
| add_action( 'init', ‘s9_remove_layouts_templates_init', 99 ); | |
| function s9_remove_layouts_templates_init() { | |
| if ( ! is_admin() ) { | |
| return; | |
| } | |
| $allowed_roles = array( 'administrator', 'super-editor', 'editor', 'author' ); | |
| $user = wp_get_current_user(); | |
| if( ! array_intersect($allowed_roles, $user->roles ) ) { | |
| // Genesis Layouts, SEO | |
| remove_action( 'admin_menu', 'genesis_add_inpost_seo_box' ); | |
| remove_theme_support( 'genesis-inpost-layouts' ); | |
| // Profile Builder Content Restriction | |
| remove_action( 'add_meta_boxes', 'wppb_content_restriction_add_meta_box' ); | |
| // SearchwP | |
| remove_meta_box( 'searchwp-related', 'post', 'normal' ); | |
| remove_meta_box( 'searchwp-related', 'article', 'normal' ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment