Header and Footer Scripts Wordpress Plugin - Restrict Access
-
Hi, need help.
How can I restrict the access to Header and Footers Script plugin/widget in Settings and Edit Pages/Post to Administrators only?Thanks.
-
Hello @llarenavera
You may add the following code to your site specific plugin OR theme's
functions.php
file:/** * Remove Header and Footer metabox from users other than Admins. * * @package: Header and Footer Scripts * @author: Anand Kumar <anand@anandkumar.net> * @link: https://goo.gl/Zjr8jp */ function remove_plugin_metaboxes(){ if ( is_plugin_active( 'header-and-footer-scripts/shfs.php' ) ) { // Only run if the user is an Editor or lower. if ( ! current_user_can( 'activate_plugins' ) ) { // Remove Metabox remove_meta_box( 'shfs_all_post_meta', 'post', 'normal' ); } } } add_action( 'do_meta_boxes', 'remove_plugin_metaboxes' );
PS: Don't forget to keep a backup handy in case anything goes wrong.
HTH
-
What do you mean site specific plugin?
Can I add this in the shfs.php file?
-
A site specific plugin is an alternative way to add custom code if you can't (or don't want) modify your theme's
functions.php
file. This link might help you understand better: https://www.wpbeginner.com/beginners-guide/what-why-and-how-tos-of-creating-a-site-specific-wordpress-plugin/