• Resolved Nik

    (@nikbond)


    I have followed various instructions to allow users with editor permissions to have admin access to Membership 2 by adding the following to wp_config.php

    define( "MS_ADMIN_CAPABILITY", "edit_pages" );

    This works fine except that these users are then defined as an Admin users (by Membership 2) and are removed from all memberships and/or can’t be re-added.

    They do not have full Admin rights, only over Membership 2, surely there must be some way of allowing them to belong to a membership?

    I’m using the User Role Editor plugin and have tried creating a separate capability eg. “msmemberadmin”, adding this to the wp_config.php as above and assigning this capabiity to users who only have “subscriber” permissions in every other way, but again, as soon as they are assigned admin rights over Membership 2, they are denied access to any memberships.

    I’m really hoping you can tell me there is a filter that will somehow allow someone to remain a member whilst also having admin rights over memberships?

    Regards
    Nik

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Support Williams – WPMU DEV Support

    (@wpmudev-support8)

    Hey @nikbond,

    Hope you’re well.

    When a member has admin rights over Membership 2 that means adding that user to one membership is useless. Because if that user can edit all memberships/members then it means can reach all memberships so you can’t limit that account to one membership.

    That’s why we don’t allow to assign membership to admin users. They should access all memberships already.

    Cheers,
    Oguz

    Thread Starter Nik

    (@nikbond)

    Hi Oguz

    I see what you mean from a limitation point of view, however, in the REAL world, most/all clubs have certain individuals who act as administrators but are still members of that club, need to pay subscriptions etc.

    In my case for example, there is a treasurer and a chairman – they record payments/update members records etc but they’re both also members of the club and pay the annual subscription fee etc.

    Are you really saying the there is no way of overriding things so that they can keep their membership AND administer other members?

    Or if you don’t know of a way, can you at least point me in the direction of the code that prevents an admin from joining a membership and perhaps I can override it myself? ??

    Regards
    Nik

    PS. I realise worst case scenario, I will have to create a separate Admin account which they log into just for editing memberships, but for various reasons, I really do not want to go down this route. Using the User Role Editor I have a achieved a very fine level of tuning admin permissions for pretty much every other aspect of the site and really find it hard to believe that Membership 2 offers no option to filter similarly.

    Plugin Support Williams – WPMU DEV Support

    (@wpmudev-support8)

    Hey @nikbond,

    Hope you’re well.

    There is no one place to check admin accounts, it makes this for many parts. So this needs to edit plugin from many parts. I also asked the developer about is there any action/filter we can use for this, but unfortunately no luck. So you need to review lots of codes here to achieve that.

    Cheers,
    Oguz

    Thread Starter Nik

    (@nikbond)

    Hi Oguz

    What I am looking for is the code that identifies a user as admin (so I can examine what criteria need to be met) and preferably the code that dictates whether or not a user can be added to a certain membership (or needs to be removed). Surely there can’t be that many different places these things are set?

    This is critical to us, to the point where even after all this time, we may not be able to use the plug-in at all if it can’t be resolved.

    Regards
    Nik

    Plugin Support Williams – WPMU DEV Support

    (@wpmudev-support8)

    Hey @nikbond,

    Hope you’re well.

    As I said this needs some customizations from different parts but let’s try one new idea. Can you open “app/model/class-ms-model-member.php” file and find this line;
    if ( is_super_admin( $user_id ) ) {
    With this;
    if ( is_multisite() && is_super_admin( $user_id ) ) {
    Then add these codes to your theme functions.php file;

    add_filter( 'ms_model_member_is_admin_user', function( $is_admin, $user_id, $capability ){
    
        $user_ids = array( 2,4,8,15,415 );
        
        if ( in_array( get_current_user_id(), $user_ids ) ){
            $is_admin = false;
        }
    
        return $is_admin;
    }, 20, 3);

    In user_ids array add the user ids that you want to manage Membership 2. Then test with one of the users you added to the array.

    Cheers,
    Oguz

    Thread Starter Nik

    (@nikbond)

    Hi @oguz

    Well this certainly looked promising (I’d tried something similar myself) but it didn’t work ??

    I’m not sure why I needed to add the clause is_multisite, since my site isn’t multisite(!) but I tried both with and without editing that line.

    Here is what I did –

    Allocate membership to user
    Allocate “Editor” permissions to user
    User’s membership is immediately deleted/removed and cannot be re-assigned until I remove the permission

    Any suggestions?

    Thread Starter Nik

    (@nikbond)

    Looking at this again, unless I’m very much mistaken, the reason the above code doesn’t work is because it is filtering on get_current_user_id() and if I’m logged in as Super Admin, it’s not MY id it should be checking but the id of the user I’m trying to allow to remain as a member AND have editor/admin rights.

    All I want to do is stop Membership 2 from removing a user from all memberships when I allocate them to an admin/editor role. Surely it can’t be that difficult? ??

    Plugin Support Williams – WPMU DEV Support

    (@wpmudev-support8)

    Hey @nikbond,

    Hope you’re well.

    Well, that’s the case ?? It’s not that easy because of the coding way of the excluding admins from memberships. When I tried with small modify the above code it looks like working for my test site, can you change the functions.php code with this;

    add_filter( 'ms_model_member_is_admin_user', function( $is_admin, $user_id, $capability ){
    
        $user_ids = array(3,4);
    
        if ( in_array( $user_id, $user_ids ) ){
            $is_admin = false;
        }
    
        return $is_admin;
    }, 20, 3);

    Don’t forget to edit $user_ids array again, please.

    Cheers,
    Oguz

    Thread Starter Nik

    (@nikbond)

    @oguz

    Just wanted to say thank you so much for this and I’m so glad I persisted because I’ve finally got at least one solution which really does seem to work… and hopefully might be useful to others in a similar situation too ??

    Warm regards
    Nik

    Plugin Support Imran – WPMU DEV Support

    (@wpmudev-support9)

    Hello @nikbond

    I trust you’re well!

    We’ve not heard from you in a while. I’ve marked this ticket as resolved for now, but if you need anything else at all, we’re here for you, please just reopen the ticket or create a new one.

    Have a good day and take care!

    Cheers,
    Nastia

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Allow a member to edit members’ is closed to new replies.