Last active
June 10, 2021 06:07
-
-
Save deckerweb/0086ebfc130633625ecbfb3093ac1a0c to your computer and use it in GitHub Desktop.
Remove Meta Boxes on Post & Page Edit Screens from "Astra" Theme and "Astra Pro" Plugin for users who are not Administrators, so Editors and below. Inspired by user question: https://www.facebook.com/groups/wpastra/permalink/367143130421624/ -- below Code Snippet should go into "Code Snippets" plugin at best (please avoid functions.php)!
This file contains 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 | |
/** Do NOT include the opening php tag */ | |
add_action( 'do_meta_boxes', 'ddw_remove_astra_metaboxes_for_non_admins' ); | |
/** | |
* Remove Astra settings meta box for users that are not administrators | |
* Inspired by: https://www.facebook.com/groups/wpastra/permalink/367143130421624/?comment_id=367167440419193&comment_tracking=%7B%22tn%22%3A%22R1%22%7D | |
* | |
* @author David Decker - DECKERWEB | |
* @link https://gist.github.com/deckerweb/0086ebfc130633625ecbfb3093ac1a0c | |
*/ | |
function ddw_remove_astra_metaboxes_for_non_admins() { | |
/** | |
* If current user has capability 'edit_theme_options' (Administrators do!) then stop running code | |
*/ | |
if ( current_user_can( 'edit_theme_options' ) ) { | |
return; | |
} | |
/** Remove meta boxes, if no Administrator: */ | |
remove_meta_box( 'astra_settings_meta_box', 'page', 'side' ); // Remove Astra Settings in Pages | |
remove_meta_box( 'astra_settings_meta_box', 'post', 'side' ); // Remove Astra Settings in Posts | |
} // end function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very useful :)