Support » Plugin: AMP » Hide AMP in side bar for specific roles (authors)

  • Resolved Anne020

    (@anne020)


    Hello,

    Is there a way to hide the ‘AMP’ plugin for specific roles? I have 60 bloggers (authors) who have access to my website and they can add their blog posts. With another plugin (role editor) I arranged that they can only see ‘Posts’ and ‘Media’ but I cannot hide ‘AMP’ in the site bar for the authors. As you can image I really don’t want my bloggers (authors) to change AMP settings for my website.
    I hope someone can help me with this or tell me how to hide AMP for my authors.

    Best,
    Anne

    The page I need help with: [log in to see the link]

Viewing 10 replies - 1 through 10 (of 10 total)
  • @anne020 While there is no option from within the plugin you can use a plugin such as “user role editor“. There is an option also using that plugin to “hide admin bar”.

    Alternatively you can use a function like the below (added to your active themes functions.php file). You’ll need to change the contributor to whatever user group you choose.

    add_action('admin_init', 'my_filter_the_plugins');    
    function my_filter_the_plugins()
    {
        global $current_user;
        if (in_array('contributor', $current_user->roles)) {
            deactivate_plugins( // deactivate for media_manager
                array(
                    '/amp/amp.php'
                ),
                true, // silent mode (no deactivation hooks fired)
                false // network wide
            );
        } else { // activate for those than can use it
            activate_plugins(
                array(
                    '/amp/amp.php'
                ),
                '', // redirect url, does not matter (default is '')
                false, // network wise
                true // silent mode (no activation hooks fired)
            );
        }
    }
    Plugin Author Weston Ruter

    (@westonruter)

    @anne020 to clarify, are you talking about the AMP item in the admin menu that appears on the left side in the admin?

    Thread Starter Anne020

    (@anne020)

    Hi Weston,

    Yes, I am talking about the AMP item in the left menu.
    In the menu where ‘Posts’, ‘Pages’, ‘Media’ and e.g. ‘Yoast’ plugin also stands.
    For my authors I only want them to see ‘Posts’ (and ‘Media’) but not ‘AMP’ (where they can change settings). Thanks for your help.

    Best, Anne

    Plugin Author Weston Ruter

    (@westonruter)

    @anne020 Thanks for clarifying. Yes, this should be hidden. At least the fields are all disabled, correct? The user can’t modify the fields even though they can access the page?

    Plugin Author Weston Ruter

    (@westonruter)

    Thread Starter Anne020

    (@anne020)

    Hi Weston, thanks for your answer. Authors can tick the check boxes in the AMP menu and than the field in the AMP menu is changing. I cannot check if AMP is totally disabled now (there was not a ‘save’ button) .. but it looks like they can modify it… I wish my authors don’t see the AMP item at all in the left menu (only adding posts and media).

    Plugin Author Weston Ruter

    (@westonruter)

    @anne020 I’ve opened a pull request with a 1.2.1-beta ZIP build attached for you to test: https://github.com/ampproject/amp-wp/pull/3005

    Thread Starter Anne020

    (@anne020)

    @westonruter Thank you! I opened the zip file but not sure what to do with it (too technical for me i guess) but the screenshots (before and after) are looking good and exactly what I need!
    Please let me know when it will be implemented and what I need to do to make it work. Many thanks indeed.

    Plugin Author Weston Ruter

    (@westonruter)

    @anne020 To test you first deactivate and uninstall your current copy of the AMP plugin. Then you go to Plugins in the admin and “Add New”. But instead of searching the directory you instead click on the Upload Plugin link and then submit the form with the ZIP file selected. Then you activate it.

    Plugin Author Weston Ruter

    (@westonruter)

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Hide AMP in side bar for specific roles (authors)’ is closed to new replies.