M2P in Network mode: Can't view members?

Okay, so we've launched our M2P-based membership scheme and things seem to be going okay (to the extent we can tell at this early stage), however...

Our M2P instance is running in network-protection mode.

While we can see billing information, new members don't show up in the M2P Members (wp-admin) page unless they have some role relating to the site that holds the M2P pages.

Since rootsite (where M2P's pages are) is pretty much only used for operational matters (such as managing memberships), this means it's going to be difficult to review current memberships, and probably difficult (or maybe impossible) to edit memberships manually if required.

Is it just me, or is this an oversight in M2P's network mode?

ETA: Something that may be relevant: I've gone to some lengths to disable M2P's account registration mechanism because it doesn't validate email addresses (and therefore provides a mechanism for spammers to create bogus accounts). Therefore, all M2P signups are done using pre-existing accounts that have no role on any site.

Maybe I need to write a hook to assign a subscriber role to rootsite on creation of new account?

  • Kasia Swiderska

    Hi David,

    ETA: Something that may be relevant: I've gone to some lengths to disable M2P's account registration mechanism because it doesn't validate email addresses (and therefore provides a mechanism for spammers to create bogus accounts).

    OK, I think that could be causing this issue, because I just tested registration for membership in network activation mode and users are added automatic to rootsite members even if they are registered on sub site. But I used registration from Membership.

    Maybe I need to write a hook to assign a subscriber role to rootsite on creation of new account?

    I will ping plugin developer, if there is way to handle this issue.

    Kind regards,
    Kasia

  • David King

    Thanks.

    I tried to hack around this with the following:

    add_action( 'user_register', 'my_new_user' );
    function my_new_user( $user_id ) {
            $res = add_user_to_blog( 1, $user_id, 'subscriber' );
    }

    But it didn't work. Looking into the SQL, the call to add_user_to_blog() set wp_usermeta k/v pairs:

    primary_blog = 1
    source_domain = $domain

    but no

    wp_capabilities = 'a:1:{s:10:"subscriber";b:1;}'

    (as I would expect) — perhaps because subscriber is the default permission level anyway. Maybe

    https://core.trac.wordpress.org/browser/tags/4.2.2/src/wp-includes/capabilities.php#L856

    explains why. I'm not sure, because I'm no WP hacker.

    Maybe the dev can shed some light on this?

  • Philipp Stracker

    Hi David,

    I have not tested this issue but your description sounds familiar.
    We will include a fix for Network-Wide mode to list all users instead of users of the current blog with the next update.

    We're still working on some important changes for that update, so I cannot say when exactly the update will be released.

    FYI - if you want to add the fix manually you just need to find the file "membership/app/model/class-ms-model-member.php"
    Then search for "function get_member_ids".
    In this function add the line I marked below:

    ...
    $args = self::get_query_args( $args, $search_option );
    $args['blog_id'] = false; // <-- This line is new in function get_member_ids()
    $wp_user_search = new WP_User_Query( $args );
    ...

    Thanks for pointing out this issue :slight_smile: Philipp