• Resolved pauliverbot

    (@pauliverbot)


    Hello Robin,
    First of all, I would like to thank you for your plugin, it is very helpful!
    I have got a question: I am working on a membership site and have specific roles. I have a kind of “Subadmin” role and this role should be able to have the “Private Groups Settings” in the Dashboard. If I turn on the “manage_options” capability for this Role, then there is way to much room for this role, because there are other plugins installed. Is there a filter to turn on the “Private Group Settings” in the Dashboard for a specific custom role?

    Thanks in advance.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Robin W

    (@robin-w)

    the default capability is as you say manage_options.

    you can amend this using

    add_filter ('rpg_plugin_settings_capability', 'rew_amend_capability') ;
    
    function rew_amend_capability() {
    $cap = 'new_capability' ;
    return $cap ;
    }

    As roles have capabilities, you can then change ‘new_capability’ in the code above to one of the capabilities that your sub admins have.

    Then put the code in your child theme’s function file –

    ie wp-content/themes/%your-theme-name%/functions.php

    where %your-theme-name% is the name of your theme

    or use
    https://en-gb.www.ads-software.com/plugins/code-snippets/

    • This reply was modified 3 years, 5 months ago by Robin W.
    Plugin Author Robin W

    (@robin-w)

    you could also create a new custom capability called say ‘private_groups_settings’

    This code adds the capability ‘hello_mother’ to the ‘simple_role’ role, so you can amend this as needed

    function rew_simple_role_caps() {
        // Gets the simple_role role object.
        $role = get_role( 'simple_role' );
     
        // Add a new capability.
        $role->add_cap( 'hello_mother', true );
    }
     
    // Add simple_role capabilities, priority must be after the initial role definition.
    add_action( 'init', 'rew_simple_role_caps', 11 );
    Thread Starter pauliverbot

    (@pauliverbot)

    Thanks Robin for your answer. I understand how to add capabilities to one specific role. But in the case above:
    $role->add_cap( 'hello_mother', true );

    How can I specify that e.g. hello_mother is the capability to have the Private Group settings in the dashboard?

    Plugin Author Robin W

    (@robin-w)

    ok, so you have two choices.

    choice 1 – use an existing capability
    choice 2 – create a specific capability

    If you want choice 2 then use all this code

    // Add simple_role capabilities, priority must be after the initial role definition.
    add_action( 'init', 'rew_simple_role_caps', 11 );
    
    function rew_simple_role_caps() {
        // Gets the simple_role role object.
        $role = get_role( 'simple_role' );
     
        // Add a new capability.
        $role->add_cap( 'private_groups_settings', true );
    }
    
    add_filter ('rpg_plugin_settings_capability', 'rew_amend_capability') ;
    
    function rew_amend_capability() {
    $cap = 'private_groups_settings' ;
    return $cap ;
    }

    and just amend ‘simple_role’ to whatever the role you are assigning to your sub admins

    Thread Starter pauliverbot

    (@pauliverbot)

    Choice 2 worked great for my specific role. Thank you very much Robin!

    Plugin Author Robin W

    (@robin-w)

    great, and thanks for the review – much appreciated ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Private Groups – Settings in Dashboard for non-Admins?’ is closed to new replies.