Multiple Membership Levels for BP/MultiSite Network using Pro-Sites

Team WPMU,

I have a problem that needs a real and immediate solution. The site I'm working on has changed direction slightly and wants to add another free level -- we launch on Monday.

The site was set up with Pro-Site and has a free level (just basic BP access, no site creation), an intermediate pay level that can create groups in BP and had a single quota-limited site, and a premium pay level that can create sites in BP and has single non-quota limited site.

The new change is to have the intermediate level now be free, still create groups, and have no blog at all.

I have Gravity forms and Pro-Site and can install Membership. Tried to do this just with Membership, but had too many problems (checkout for free levels was completely jacked up and it still showed the "Create a Group" link to all members despite the access restrictions).

Any ideas? Need some help here!

  • jetmac

    I am using Pro-Sites.

    I tried using Membership, because it does seem more appropriate for what I want to do. However, Membership's checkout and user management simply is not up to the task for this application - I'm sure it works great for a single site, but I am running into too many issues trying to get it to work properly. It's workflow is backwards and it seems to get really confused when network activated.

    The bottom line is: I want to specify two distinct free levels and one paid level in Pro-Sites. I do not want a member to have to go through the checkout process for a free level, that seems very amateur.

    I need these three levels:

    1. Reader - able to participate freely in BP network, but can not create books or a blog. - Free level

    2. Author (basic) - same as Reader except CAN great groups and CAN create a limited blog (yes, it changed back) - Free level

    3. Author (premium) - same as Author (Basic) but has a blog without quota limits - Paid level

    How can I do this?

  • aristath

    It's workflow is backwards and it seems to get really confused when network activated.

    That's because when network-activated, the plugin works on a pre-site basis. So each site has to be separately configured...

    Pro-Sites only applies to users that own a blog. If they don't own their own site, then they have no pro-sites level.

    What you want to do will probably require a lot of custom coding!
    Here's a sample code that you can use and expand to suit your own use-case:

    global $wpdb;
    // get the ID of the current user
    $user_ID = get_current_user_id();
    // Get the blogs that belong to this user
    $user_blogs = get_blogs_of_user( $user_ID );
    
    foreach ( $user_blogs as $user_blog) {
      $blogid = $user_blog->site_id;
      $sql = "SELECT level FROM {$wpdb->base_prefix}pro_sites WHERE blog_ID = '$blog_id'";
      $level = $wpdb->get_var($sql);
      if ( $level == 1 ) {
        $max_level = 1;
      } elseif ( $level == 2 && $max_level < 2 ) {
        $max_level = 2;
      } elseif ( $level == 3 && $max_level < 3 ) {
        $max_level = 3;
      }
    }
    
    if ( $max_level == 1 ) {
      // Do something if the user's blogs are maximum level 1.
      // If for example they have a blog that is level 2, this will not be done.
    }
    
    if ( $max_level == 2 ) {
      // Do something if the user's has a blog that is level 2, but not anything above that.
    }
    
    if ( $max_level == 3 ) {
      // Do something if the user's has a blog that is level 3.
    }

    The code that checks if a site is on a specific level is this:

    global $wpdb;
    $blog_id = $wpdb->blogid;
    $sql = "SELECT level FROM {$wpdb->base_prefix}pro_sites WHERE blog_ID = '$blog_id'";
    $level = $wpdb->get_var($sql);
    
    if ($level == 1) {
      // Do something
    } elseif ($level == 2) {
      // Do something
    } elseif ($level == 2) {
      // Do something
    }

    The above code simply goes through ALL the current user's blogs, finds the maximum level that a blog owned by that user has, and then builds the conditionals based on that.

    These are simply to check the pro-sites level using PHP, but you can expand on these and write your own code so that the appropriate action is taken based on what they have.

    I hope that helps!

    Cheers,
    Ari.