[Membership 2 Pro] How to assign a Membership to an admin user

I have a multisite installation. I don't want individual subsites to be able to install addons to plugins, or to change some settings, hence I want to limit the options of the admin user.
I cannot do that with Membership 2 Pro, as it doesn't allow assigning a membership to an admin user.
I have tried setting up a new user role with user role editor plugin, and assigned that new role to the administrator, but still it recognizes the user as WP administrator and doesn't let assign a membership.
How to limit the options of an admin in the admin area?

  • Ash

    Hello mpress

    A membership can't be assigned to an admin user I am afraid. All admin users are membership admin by default.

    If you allow a new role to an admin user but that role still has manage_options capabilities, that will still be treated as admin.

    I think you can admin menu editor plugin: https://wordpress.org/plugins/admin-menu-editor/

    This will allow you show/hide menus based on capability, so the user still can be admin but having an extra capability will allow him to access an extra menu.

    Hope it helps! Please feel free to ask more questions if you have any.

    Have a nice day!

    Cheers,
    Ash

  • mpress

    When setting up the membership, I observe that 3 admin options are reset automatically by Membership 2 Pro back to "Handled by WordPress". These are Media Categories, Event Categories and Testimonial Categories.
    At first the assignment of the membership is accepted, but refreshing the page shows "Handled by WordPress".
    Why's that? How to resolve?

    Many options that are selected for the membership do not appear in the admin menu.
    I list them here:
    Home statistics, YouTube free, Event settings, (BuddyPress) Emails, Horizontal scroll, Appearance emails, Users modify profile, manage applications and profile fields, Tools export personal data, delete personal data, regenerate thumbnails, Shortcodes, Appointments, Autoblog, Forminator, (BuddyPress) Groups, Membership 2 add member.
    Why's that, and how to resolve?

    I like the plugin and the wide range of features it has, but I am confused about this admin part.

    Hope you can help.

  • Luís

    Hi mpress ,

    Hope you're doing well today!

    When setting up the membership, I observe that 3 admin options are reset automatically by Membership 2 Pro back to "Handled by WordPress". These are Media Categories, Event Categories and Testimonial Categories.
    At first the assignment of the membership is accepted, but refreshing the page shows "Handled by WordPress".

    I was able to replicate this issue in my site too with the "Event -> Categories" menu item. I have reported this issue to the developer so they can fix it asap.

    Many options that are selected for the membership do not appear in the admin menu.
    I list them here:
    Home statistics, YouTube free, Event settings, (BuddyPress) Emails, Horizontal scroll, Appearance emails, Users modify profile, manage applications and profile fields, Tools export personal data, delete personal data, regenerate thumbnails, Shortcodes, Appointments, Autoblog, Forminator, (BuddyPress) Groups, Membership 2 add member.
    Why's that, and how to resolve?

    I am afraid those menu items will require the manage_options capability. I made some tests in my site with the "Event -> settings", "Forminator", "Membership 2". These menu items just appeared when the manage_options capability was assigned to the user role. So I suppose the same is happening with the other menu items too, even with permission to access via "Admin side" protection add-on (membership2), the user role doesn't have capabilities. Can you check test this on your side too?

    I hope this information has been helpful. If I can help you in this or other related question, please let me know!

    Cheers, Luís

  • mpress

    Luis, thanks for passing the first issue to the developer.

    Re the second issue: you are right. I have activated the manage_options capability, and he has indeed all options now in the dashboard.
    So that's ok for the admin user. I was trying to limit his options in the admin menu, but I can live with the full option set.

    But... why are options like Shortcodes, Horizontal scroll, BuddyPress Groups and Forminator only available for the admin? I would like to see those available for e.g. an editor as well.
    Plus: I noticed that also eNewsletter is not appearing to the editor role? Pages are not available to the editor role at the moment either.

    I don't feel comfortable with the Protection Rules for the Admin Side at the moment. It doesn't seem to show quite some options to non-admin users.
    What am I doing wrong??

  • Nithin

    Hi mpress,

    Hope you are doing good today. :slight_smile:

    I have tested with the user fleur for the subsite called location.
    Re Adminimize: I am trying to minimize the number of plugins. I was using both Adminimize and Membership 2 Pro, but if the latter can protect the admin access as well, then that's one plugin less.

    Following you up for the above question asked in this ticket:
    https://premium.wpmudev.org/forums/topic/membership-2-pro-some-options-in-admin-menu-cannot-be-hidden-with-membership-2-pro?replies=6#post-1376306

    I checked the user "fluer", and I could notice it's using a custom user role(Redacteur-beperkt), from your response in the current ticket it seems like the role has "manage_options" capabilities, correct?

    If yes, the manage_options in an default admin capabilities, as listed in here:
    https://codex.wordpress.org/Roles_and_Capabilities#Capability_vs._Role_Table

    And one of the capabilities what M2 plugin will check to see whether the user is admin, or not is the "manage_options" capabilities.

    You can find it's listed in the plugin side, under /membership-pro/app/controller/class-ms-controller-plugin.php

    /**
         * Capability required to count as M2 'admin' user. Admin users have full
         * access to all M2 features.
         *
         * @since  1.0.0
         *
         * @var $capability
         */
        protected $capability = 'manage_options';

    So, the Admin Side Protection rules added for such user roles won't work out of the box, and it'll be treated as an admin user due to the above use case.

    I checked regarding this with the developer, and he have stated the Admin side protection add-on won't work for users with capabilities "manage_options".

    Could you please confirm whether this is how you are trying to make it work? If yes, I could check with our Second Level Support(SLS) team to see whether there could be a quick workaround regarding this.

    Please do note that, if our SLS team finds it too complex, they might direct you to custom coding. Will keep you posted once I get further updates regarding this from asap.

    However, the easiest workaround would be better to make use of Adminize plugins to hide menus based on capabilities, or roles.

    But... why are options like Shortcodes, Horizontal scroll, BuddyPress Groups and Forminator only available for the admin? I would like to see those available for e.g. an editor as well.
    Plus: I noticed that also eNewsletter is not appearing to the editor role? Pages are not available to the editor role at the moment either.

    This is how WordPress works in general, the Editor role is meant to be used for only to edit/delete/add page/post, hence advanced changes, and edits in a plugin is only available to admin users.

    Please advise if I had missed anything before I bring this into our SLS teams attention, looking forward to your response. Have a nice day ahead. :slight_smile:

    Regards,
    Nithin

  • mpress

    Hi nithin,

    User fleur has a user-defined role called "editor-limited". It is a limited version of the normal edit role, in the sense that it does not allow editing of pages. The manage_options capabilty in unchecked.
    So my answer is "no", user fleur is not an admin user.

    She is a limited-editor user, who cannot edit pages. She has an Membership 2 Pro "editor" membership type assigned to it, where I defined that she should have access to the eNewsletter options, as well as the shortcodes options in the admin menu. But these options do not appear in her admin menu.

    I have listed previously a whole number of options that - although set in the Membership 2 Pro membership type - do not appear in the admin menu. These are:
    Home statistics, YouTube free, Event settings, (BuddyPress) Emails, Horizontal scroll, Appearance emails, Users modify profile, manage applications and profile fields, Tools export personal data, delete personal data, regenerate thumbnails, Shortcodes, Appointments, Autoblog, Forminator, (BuddyPress) Groups, Membership 2 add member.

    For some I can understand that they related to the admin function, i.e. the manage_options capability checked. But certainly not all.
    From Louis' response I read that all these options relate to the manage_options capabilty:
    "I am afraid those menu items will require the manage_options capability. I made some tests in my site with the "Event -> settings", "Forminator", "Membership 2". These menu items just appeared when the manage_options capability was assigned to the user role. So I suppose the same is happening with the other menu items too, even with permission to access via "Admin side" protection add-on (membership2), the user role doesn't have capabilities. Can you check test this on your side too?

    Why would e.g. Formulator forms that are sent only be available to the admin function? Or adding a Membership 2 member? Or the examples of the shortcodes? Or the horizontal scroll?

    Summarized: Many options that I want to give access to in the Membership 2 Pro admin menu function do not appear in the admin menu. Is that really because all are limited to the admin function only?
    If not (hopefully not...), how to have these options appearing in the admin menu?

    Thanks for your explanation & help.

    (I understand some are indeed related to admin function)

  • Nithin

    Hi mpress,

    User fleur has a user-defined role called "editor-limited". It is a limited version of the normal edit role, in the sense that it does not allow editing of pages. The manage_options capabilty in unchecked.
    So my answer is "no", user fleur is not an admin user.

    If the user doesn't have manage_options capabilities, it should have worked. Apart from the Editor capabilities, could you please list the capabilities what the user has or what capabilities was removed, so that I could test this out in my side too?

    She is a limited-editor user, who cannot edit pages. She has an Membership 2 Pro "editor" membership type assigned to it, where I defined that she should have access to the eNewsletter options, as well as the shortcodes options in the admin menu. But these options do not appear in her admin menu.

    This part is a bit confusing for me, so please do advise, if I missed anything. Could I know how you defined the user would have access to enewsletter options?

    By default the eNewsletter menu option for the "Editor" role is only to subscribe to newsletter, as shown in the screenshot:

    The "Editor" role won't have access to configure eNewsletter, that's the role of the admin. If you meant the above page shared in the screenshot isn't visible for the user, then it could be more of a capability issue being set wrong, and that needs to be looked upon.

    It's upto the plugin to set which user roles should have access to editing the plugin settings, if it's set to "manage_options" in plugin side, then only a user with "manage_options" capability could access those menus. In case of eNewsletter it's set to display the above page for editor role, and for admin role the page accessible would be different.

    From Louis' response I read that all these options relate to the manage_options capabilty:
    "I am afraid those menu items will require the manage_options capability. I made some tests in my site with the "Event -> settings", "Forminator", "Membership 2". These menu items just appeared when the manage_options capability was assigned to the user role. So I suppose the same is happening with the other menu items too, even with permission to access via "Admin side" protection add-on (membership2), the user role doesn't have capabilities. Can you check test this on your side too?

    So, if the Memberships admin side protection add-on isn't working for menus which is supposed to list for Editor role, then that's an issue which needs to be given a closer look.

    What Luis stated is for the plugins like Events+, Forminator & Membership 2 Pro, which will not display any menu for "Editor" role, but if "manage_options" capabilities is added, then it worked for him, and the menus were visible.

    But adding "manage_options" would treat the user as an admin in Membership 2 Pro, and we wouldn't be able to assign a membership manually to such user roles, nor protect any contents because the user is treated as an admin.

    I tried to assign a membership to a user who has Editor capability plus "manage_options", and I couldn't assign a membership via the plugin dashboard.

    I could only assign a membership once the "mange_options" capability was removed to that user.

    Why would e.g. Formulator forms that are sent only be available to the admin function? Or adding a Membership 2 member? Or the examples of the shortcodes? Or the horizontal scroll?

    This is how WordPress works by default. The "Editor" roles by default will only have permission to add/edit/delete post, and pages. That's the only function the Editor is meant for in WordPress.

    For feature higher than that, it would require an admin role, so the plugin would check whether the user is an admin, or not by checking whether the role has "manage_options", and then would display the plugin settings based on that in the dashboard.

    Hence these menu won't be listed to a user with "Editor" role. So, the user with "Editor" role won't have access to Events plugin, Forminator, or Membership 2 Pro menus, as these plugins are only meant to be used for admin roles.

    Seems like the support access to the site isn't enabled, so I wasn't able to check, or test about the issue faced with user "fleur". If it's only Editor role, then admin side protection add-on should work fine.

    Please enable support access, so that I could give a closer look regarding this too. Have a nice day ahead. :slight_smile:

    Regards,
    Nithin

  • mpress

    Hi nithin,

    I have granted you access. Please have a look at the subsite "locatie".

    I understand that for the various settings options in the admin menu one needs the admin role.
    But there are many other options for Appointments, Events, Forminator, eNewsletter, that may well be assigned to an editor role:
    - Appointments: Appointments
    - Events: Events, Add Event & Shortcodes
    - Forminator: Submissions
    - eNewsletter: Reports, Newsletters, Create Newsletter, Member Groups & Members
    - Shortcodes: Available shortcodes
    Can you please explain why I cannot give access to these options to users with editor role?

    My client has lots of volunteers. The user admin is not an admin role, but they want it to be assigned to a separate role. That's why I created the user admin role (ledenadmin in Dutch) in WP, and a Ledenadmin membership role. This membershiptype has activated all the options related to users in WP, Membership 2 Pro, BP Groups. See the attachment.
    But... nothing appears in the admin menu.
    Please advise why, and how to get these options available.

    Please understand that we want to limit the number of admin users, for obvious reasons.

  • Nithin

    Hi mpress,

    It seems like the website is still not accessible in my side, I get the following message:

    However, I could access the site via proxy IP. Either the country India is blocked, or it's something specific within DNS side.

    I understand that for the various settings options in the admin menu one needs the admin role.
    But there are many other options for Appointments, Events, Forminator, eNewsletter, that may well be assigned to an editor role:
    - Appointments: Appointments
    - Events: Events, Add Event & Shortcodes
    - Forminator: Submissions
    - eNewsletter: Reports, Newsletters, Create Newsletter, Member Groups & Members
    - Shortcodes: Available shortcodes
    Can you please explain why I cannot give access to these options to users with editor role?

    Since we don't have a background on how these roles works, and what all menus are supposed to show in general. This needs to be tested further in your system to be sure what's exactly causing the issue.

    Which will require disabling the M2 plugin to see how the roles are supposed to work in general, and then testing with the use roles individually, and with M2 enabled, so that we could have a better idea what's causing the Admin Side add-on to not work etc.

    At the moment the M2 plugin seems to be network activated, so I'm not sure whether running such test would be fine in your live site. If you aren't comfortable with running the above test, is there a way to setup a staging(clone) site, so that we could test this out easily without causing any issue in the live site?

    Asking the hosting provider to setup a staging site, or using plugins like Shipper Pro should help with creating a staging.

    Could you please let me know how you want us to troubleshoot this further, so that we could have a better idea how the roles are meant to work in general, and what's causing it.

    If you have configured a staging site then, you can send credentials by using our secure contact form: https://premium.wpmudev.org/contact/#i-have-a-different-question

    - To Mark to my attention, the subject line should contain only: ATTN: Nithin Ramdas
    -WordPress admin username
    -WordPress admin password
    -login url
    -FTP credentials (host/username/password)
    -link back to this thread for reference
    -any other relevant urls

    Please do follow up in the ticket once you have sent the above credentials. Have a nice day. :slight_smile:

    Kind Regards,
    Nithin

  • mpress

    Getting back to my original question: How to assign a membership to an admin user.
    I've read the following
    "Define Membership 2 Admin users
    By default all users with capability manage_options are considered Membership 2 admin users and have unlimited access to the whole site (including protected content). To change the required capability add the line define( "MS_ADMIN_CAPABILITY", "manage_options" ); in wp-config.php. When you set the value to false then only the Superadmin has full access to the site."

    If I understand it correctly, I have to include the following instruction to wp-config.sys:
    define( "MS_ADMIN_CAPABILITY", "manage_options", false );
    Is that correct?

    I see no effect.
    What effect on the admin menu should this have for the admin role?

    Hope you can explain.

  • Nithin

    Hi mpress,

    Sorry for the delay regarding this. I tested further regarding this in your system, by creating a new user wpmutest, and assigning the roles "Ledenadmin" & "Redacteur-beperkt". This is what I could see with the dashboard with only "Ledanadmin" & "Redacteur-beperkt" role assigned:

    And this is how when it comes to Membership 2 Pro plugin enabled:

    It should have worked in your use case, however, the role "Ledanadmin" seems to conflict when M2 plugin is activated, the roles works fine as expected when M2 is disabled.

    I'm afraid, this would require further troubleshooting, and I'm bringing this into our Second Level Support(SLS) teams attention, to see what exactly is being missed and whether there is any workaround regarding this.

    Please do note that SLS works in complex issues, and have a slow response time. Will keep you posted once we get further feedback regarding this asap.

    If I understand it correctly, I have to include the following instruction to wp-config.sys:
    define( "MS_ADMIN_CAPABILITY", "manage_options", false );
    Is that correct?

    It should be:

    define( "MS_ADMIN_CAPABILITY", false );

    However this doesn't seem to help much with the custom roles created in your website.

    Regards,
    Nithin

  • Tho Bui

    Hi mpress,

    I hope you're well today!

    Regarding your issue, our developers are already working on this. In the meantime, all you need to do is download the attached file, unzip it and place it inside wp-content/plugins/membership-2/app/premium/rule/adminside/class-ms-rule-adminside-model.php, replace as new one.

    I would strongly suggest to keep a backup of original file, eg by renaming them to something like:
    class-ms-rule-adminside-model.php.back

    About the Groepen menu, that requires user to have the manage_options cap so Membership can't override it. That's why members can't vew this.

    Kind regards,
    Tho Bui

  • mpress

    Hi Tho Bui,

    Sorry for my late reply, and thanks for this fix.
    I can confirm that it do the job: multiple memberships are now both reflected in the admin area.

    Re the Groups (Groepen) menu: not a big issue, I have found a work around for this: through a menu in the frontend.

    I started this thread for a couple of issues, of which most are resolved. The only open issue seems some options to be only available to the admin user. I will further investigate that part. I will close this thread now, and if necessary, I will open a new thread specifically for admin menu options that are set in membership levels but don't appear. But only if necessary.

    Thanks for now, it is so much better already!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.