User Roles

When a user creates a site using pro sites, they are automatically assigned a user role of admin for their own website.

Is there a way for these same users to become a user of my main primary site with an assigned user role.

ie.

User A - Signs up for a free blog - Is assigned as a subscriber on my site.
User B - Signs up to a premium pro site - Is assigned as a 'member' on my site.

I can then give User B additional privileges and access to areas of my site that only members are allowed...

  • Luís

    Hi Brett ,

    Hope you're doing well today!

    Firstly, sorry for my late reply and all the problems it may have caused.

    Can you try add this code to your theme functions.php

    add_action('prosites_before_checkout_page', 'update_user_role');
    function update_user_role() {
        if( !is_user_logged_in() || is_super_admin() || empty( $_GET['bid'] ) ) {
            return;
        }
        global $current_site;
    
        //If current user is admin
        $curr_blog = $_GET['bid'];
        $blog_admin = get_user_by( 'email', get_blog_option($curr_blog, 'admin_email'));
        //Check if pro user
        if( function_exists('is_pro_user') && is_pro_user( $blog_admin->ID ) ) {
            add_user_to_blog( $current_site->blog_id, $blog_admin->ID, 'editor' );
        }
        return;
    }

    When an administrator visits the Pro Sites page, if he/she is a "pro user", will get the "editor" role on main site. This code will work for all the users, existing and new ones.

    Cheers, Luís

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.