are there custom capabilities for store settings tabs?

hello there

i have some users on my website that can manage the marketpress products. they have typically an editor role. but those users should also be able to edit the coupons. i manage the roles through a plugin and i could give those users a "manage_options" capability. but then they could also edit the wordpress settings, which isn't that cool. and i didn't see any custom capabilities defined by marketpress or didn't i look closely enough?

so, it would be very nice to have some custom capabilities for every settings tab. is this an existing or planned feature? or how could i accomplish my task with the current plugin version?

thanks for the help

  • DavidM
    • DEV MAN’s Mascot

    Hi baum,

    Fortunately, there's a filter for that!
    On line 4224 (in the current version 2.1.1) you'll see the following:
    $tabs = apply_filters( 'marketpress_tabs', $tabs );

    You can easily add a filter to restrict the tabs as you like them, perhaps customizing display of the tabs per user role. You can use the code from line 4224 to 4232 as an example to help.

    I'll bookmark this thread and try and get back to providing that if I get some free time, as it really is a useful one I think, a great idea to restrict the tabs based on user roles.

    Cheers,
    David

  • baum
    • Flash Drive

    thanks for the tip. i've restricted the tabs successfully. but i don't see how i could remove the "general" tab from the output because it isn't in the $tabs array. it is added seperately at line 4227. any idea on this?

    my current code:

    if ( current_user_can( 'manage_options' ) )
    {
        $current_user = wp_get_current_user();
        $roles = $current_user->roles;
        $role = array_shift($roles);
    
        if( $role == 'editor' )
        {
            $tabs = array(
                'coupons' => __('Coupons', 'mp')
            );
        }
    }
  • dfstorm
    • Site Builder, Child of Zeus

    Im using the justin tadlocks members plugin and marketpress on a worpress multisite. I want to be able to give users of a certain role "shopowners" access to the marketpress plugin so they can create there own products. but marketpress and the members plugin dont seem to work together straight out of the box. No marketpress capability options are available.

    Do i need to add the marketpress capabilities in manually through the members plugin? if so, what are the capabilites that i need to add?

    I can see this post has listed some php code to restrict the tabs that display to certain users.

    if ( current_user_can( 'manage_options' ) )
    {
    $current_user = wp_get_current_user();
    $roles = $current_user->roles;
    $role = array_shift($roles);

    if( $role == 'editor' )
    {
    $tabs = array(
    'coupons' => __('Coupons', 'mp')
    );
    }
    }

    what document do i put this code into?

  • dfstorm
    • Site Builder, Child of Zeus

    that would be great. I just want the users to have access to the marketpress shop in the admin. thats all. That way they wont get confused by other admin options. And it makes it hard for them to break stuff. So how long until this feature is available do think?

  • dfstorm
    • Site Builder, Child of Zeus

    No worries. I'll let my client know. In the meantime however. Has anyone come across any modules that help you custormize the admin area for a certain user role? I know there is a couple out there but i haven't played with them.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.