Enabling non admins to create groups


Home Forums Front End PM PRO Enabling non admins to create groups

This topic is: Resolved
Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #42929
    Denis Marchand
    Participant

    Hi,

    Apparently the [manage_options] capacity is needed to be able to create FEPM groups. However, I want some non admin users to be able to create groups. So, I have added them as new FEPM admins. This doesn’t seem to have any effect and they are still unable to access the Group creation panel via the dashboard.

    What am I missing ?

    Thanks in advance.

    Patrick

    #42932
    Denis Marchand
    Participant

    Hi again,

    By the way, I have added a new FEPM admin abd authorized users to send messages to the admin(s), but when I click on New message from a user’s account, I see the “send message to admin checkbox” but I have no choice (as if the new admin was not registered).

    Patrick

    #42934
    Denis Marchand
    Participant

    Hi,

    OK. The “send message to “admin” thing is a bug. If I add only one new admin, it doesn’t appear as a possible choice. If I add a second one, the first one appears as a choice in the list but not the second and so on…

    Thanks in advance for fixing this.

    Patrick

    #42937
    Shamim Hasan
    Keymaster

    1. You can use register_post_type_args hook to change which capability we need to create groups. (If you need more instruction let me know)
    2. You can follow https://www.shamimsplugins.com/docs/front-end-pm-pro/getting-started-2/only-admin/ for admin setup. If only one admin is set then that will not show as as choice. Message sent to admin will go directly to that admin.
    3. I could not reproduce the issue where if we have 2 admins, one is hidden. Can you please re-test this?

    #42939
    Denis Marchand
    Participant

    Hi Shamin,

    > 1. You can use register_post_type_args hook to change which capability we need to create groups. (If you need more instruction let me know)

    Yes, I would appreciate some guidance.

    > 3. I could not reproduce the issue where if we have 2 admins, one is hidden. Can you please re-test this?

    I have retested by adding a third admin and now I see all three. However, I should have mentioned that when I did the previous test, I had previously added and then deleted a new admin.

    Thanks for the quick answer.

    Patrick

    #42953
    Shamim Hasan
    Keymaster

    Add following code in your theme’s (child theme’s if you are using) functions.php

    add_filter( 'register_post_type_args', function( $args, $post_type ){
        if( 'fep_group' == $post_type ){
            $args['capability_type'] = 'manage_options'; //Change this as you need
        }
        return $args;
    }, 10, 2);
    

    Let me know

    #42963
    Denis Marchand
    Participant

    Hi Shamim,

    Thanks for the code. However, I’m afraid this will not be enough.

    I have created a custom capability (manage_fepm_groups), gave it to the author role and used it in the code you provided. The FEPM menu doesn’t even appear in their dashboard.

    This can be fixed by giving the authors the ‘page’ capability but even then, the access to edit.php?post_type=fep_group is not allowed.

    I have seen that the manage_options capability is hard-coded everywhere in the code.So, I think that giving access to the All Groups page to authors and editors will require modifying this code directly. Something I don’t want to do for obvious reasons.

    Patrick

    #42965
    Denis Marchand
    Participant

    Hi Shamim,

    I have tried again and again to use the filter you mentioned above but each time a non admin user tries to access “edit.php?post_type=fep_group”, he’s blocked because he has not enough rights. The page itself is probably accessing other pieces of code requiring the manage_options capability.

    I could replace manage_options with another custom capability all over the code but the next update will overwrite these changes. Not a good solution.

    I think that you should consider making this configurable. Group Messaging is one of the main reasons for which we decided to switch to the Pro version. In its current state, if people involved in the site activity but who should not be admins and shouldn’t have the manage_options capability need to create an FEPM group, they have to ask an admin. This is not practical and I’m getting flak about that.

    My two cents.

    Patrick

    #42967
    Shamim Hasan
    Keymaster

    Can you please try following code along with above code

    add_filter( 'fep_admin_cap', function( $admin_cap ){
        return 'manage_options';
    });
    

    Change capability here as well. This will give that user admin capability (eg. see all messages etc), so use with caution
    Let me know.

    #42969
    Denis Marchand
    Participant

    Hi again,

    By the way, I have just noticed that users having the Editor role, do have the FEPM => All Groups menu in their dashboard. However, when clicking on All Groups, access is denied. So, it seems that giving access to All Groups to editors was anticipated but not really implemented.

    I didn’t see this before because I’m essentially working on the Author role. No user has the editor role for the moment (except a test account).

    Patrick

    #42971
    Denis Marchand
    Participant

    Hi Shamim,

    I changed the code as suggested using a custom capability. Now, authors and editors do have access to the whole FEPM menu (as you said, this is risky) but admins no longer see the FEPM | All Groups menu.

    Not a satisfactory solution, I’m afraid.

    I’ll see if I can work out something that would allow editors and authors to only have access to the FEPM | All Groups menu.

    Patrick

    #42973
    Shamim Hasan
    Keymaster

    can you try following code

    add_filter( 'register_post_type_args', function( $args, $post_type ){
        if( 'fep_group' == $post_type ){
            $args['show_in_menu'] = true;
        }
        return $args;
    }, 10, 2);
    

    It should show a separate menu for Groups

    #42977
    Denis Marchand
    Participant

    Hi Shamim,

    OK. I got it working but with some additional efforts. Here are the steps to follow. This can possibly help others…

    1. Create a custom capability. In my case manage_fepm_groups.

    2. Assign this capability to all roles you want to be able to manage groups without having access to the full FEPM management system.

    3. Add the following code to functions.php ::


    add_filter( 'register_post_type_args', function( $args, $post_type ){
    if( 'fep_group' == $post_type ){
    $args['show_in_menu'] = true;
    }
    return $args;
    }, 10, 2);

    add_filter( 'fep_admin_cap', function( $admin_cap ){
    return 'manage_fepm_groups';
    });

    4. Now all roles having the manage_fepm_groups capability (in my case admins, editors and authors) have 2 FEPM related menus in their dashboard : Front End PM Pro (full management options without the All Groups entry) and Groups (Group management). This obviously not what we want.

    5. Use an admin menu editor (I use Menu Editor) to make all the entries of the Front End PM PRO menu inaccessible to non admins. In Menu Editor this can be done by adding for each entry an additional extra capability that will be mandatory to access these menu entries. I entered manage_options in this field and saved the menu changes.

    After that, the Front End PM PRO menu disappeared for authors and editors but was still there for admins (who are keeping the All Groups menu anyway which is indispensable because it is no longer there in the Front End PM PRO menu). Authors and Editors are now able to manage groups.

    Well, I got what I wanted but this was a little bit awkward, to say the least 🙂 .

    Thanks anyway for putting me on the right track. But I think that the possibility to give access to group management to non admins should be built-in.

    Greeting from Fontainebleau, France.

    Patrick

    #42979
    Denis Marchand
    Participant

    Ooooops !

    I forgot to mention that you also have to give authors the capability to edit, delete and publish pages. It’s not needed for editors.

    Patrick

    #42982
    Shamim Hasan
    Keymaster

    Can you please try only following code? (remove fep_admin_cap code)

    add_filter( 'register_post_type_args', function( $args, $post_type ){
        if( 'fep_group' == $post_type ){
            $args['show_in_menu'] = true;
            $args['capability_type'] = 'post';
        }
        return $args;
    }, 10, 2);
    

    Let me know. This way you do not need to give other users admin access then modify by other plugin.

Viewing 15 posts - 1 through 15 (of 16 total)

You need to purchase ‘Front End PM PRO’ to create topic in this support forum.

If you already purchased ‘Front End PM PRO’ please LOGIN.