Change WordPress user roles and capabilities Forums How to or FAQ Add access to code snippet plugin

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #7452
    bsahin
    Participant

    Hello,

    I want “shop manager” role to edit code snippet plugins.

    What should I do for this?

    #7456
    Vladimir
    Keymaster

    Hi,

    Send a link to plugin at wordpress.org/plugins in order we talk about the same plugin.

    #7457
    bsahin
    Participant
    #7459
    Vladimir
    Keymaster

    Hi,

    Code Snippets plugin uses ‘manage_options’ user capability and ‘manage_network_options’ for the WordPress multisite.
    It allows to replace default user capability via custom filters:
    code_snippets_cap :

    
    /**
    * Retrieve the name of the capability required to manage sub-site snippets
    *
    * @return string
    */
    public function get_cap_name() {
    	return apply_filters( 'code_snippets_cap', 'manage_options' );
    }
    

    and
    code_snippets_network_cap:

    
    /**
    * Retrieve the name of the capability required to manage network snippets
    *
    * @return string
    */
    public function get_network_cap_name() {
    	return apply_filters( 'code_snippets_network_cap', 'manage_network_options' );
    }
    

    Take into account that user who can execute PHP code at the site server can get superadmin access in a minute. You should trust to such person.

    #7461
    bsahin
    Participant

    Hi Vladimir,
    So if I add these snippets to code snippet plugin, then I can assign shop manager to change it. (just example)

    Yes, I am aware the risk, but we have to change some snippets by daily basis.

    thanks for warning.

    #7463
    Vladimir
    Keymaster

    You don’t need to add these snippets to CS plugin. I took them from its source code to show you the possibility to change ‘manage_options’ to any other user capability.
    If do not change that, just grant ‘manage_options’ capability to shop manager. It will get access to the ‘Snippets’ admin menu. Also it will get access to all other admin menu items, protected by ‘manage_options’, like ‘Settings’ for example. You can block them using “Admin menu access” add-on included into URE Pro.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.