Navigation

    Digital Liberation Forums

    • Register
    • Login
    • Search

    Header and Footer Scripts Wordpress Plugin - Restrict Access

    Header and Footer Scripts
    2
    4
    497
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • L
      llarenavera last edited by

      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. 🙂

      anand 1 Reply Last reply Reply Quote
      • anand
        anand @llarenavera last edited by

        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

        1 Reply Last reply Reply Quote
        • L
          llarenavera last edited by

          What do you mean site specific plugin?

          Can I add this in the shfs.php file?

          1 Reply Last reply Reply Quote
          • anand
            anand last edited by

            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/

            1 Reply Last reply Reply Quote
            • First post
              Last post