private function setUserRole($userId)
    {
        if (is_multisite()) {

            //Init sites if not done
            if (is_null($this->sites)) {
                $this->initSites();
            }

            //Get role (superadmin should always be administrator)
            if (is_super_admin($userId)) {
                $role = "administrator";
            } else {
                $role = $this->defaultRole;
            }

            //Bulk add (or just this site)
            if (defined('AD_BULK_IMPORT_PROPAGATE') && AD_BULK_IMPORT_PROPAGATE === true) {
                foreach ($this->sites as $site) {
                    if (is_user_member_of_blog($userId, $site->blog_id) === true) {
                        continue;
                    }
                    add_user_to_blog($site->blog_id, $userId, $role);
                }
            } elseif (is_user_member_of_blog($userId, get_current_blog_id()) !== true) {
                add_user_to_blog(get_current_blog_id(), $userId, $role);
            }
        } else {
            if (isset(get_userdata($userId)->roles) && !empty(get_userdata($userId)->roles)) {
                return false;
            }
            wp_update_user(array('ID' => $userId, 'role' => $this->defaultRole));
        }
    }
private function setUserRole($userId)
    {
        if (is_multisite()) {

            //Init sites if not done
            if (is_null($this->sites)) {
                $this->initSites();
            }

            //Get role (superadmin should always be administrator)
            if (is_super_admin($userId)) {
                $role = "administrator";
            } else {
                $role = $this->defaultRole;
            }

            //Bulk add (or just this site)
            if (defined('AD_BULK_IMPORT_PROPAGATE') && AD_BULK_IMPORT_PROPAGATE === true) {
                foreach ($this->sites as $site) {
                    if (is_user_member_of_blog($userId, $site->blog_id) === true) {
                        continue;
                    }
                    add_user_to_blog($site->blog_id, $userId, $role);
                }
            } elseif (is_user_member_of_blog($userId, get_current_blog_id()) !== true) {
                add_user_to_blog(get_current_blog_id(), $userId, $role);
            }
        } else {
            if (isset(get_userdata($userId)->roles) && !empty(get_userdata($userId)->roles)) {
                return false;
            }
            wp_update_user(array('ID' => $userId, 'role' => $this->defaultRole));
        }
    }
private function setUserRole ( $ userId ) { if ( is_multisite ( ) ) { //Init sites if not done if ( is_null ( $ this -> sites ) ) { $ this -> initSites ( ) ; } //Get role (superadmin should always be administrator) if ( is_super_admin ( $ userId ) ) { $ role = "administrator" ; } else { $ role = $ this -> defaultRole ; } //Bulk add (or just this site) if ( defined ( 'AD_BULK_IMPORT_PROPAGATE' ) && AD_BULK_IMPORT_PROPAGATE === true ) { foreach ( $ this -> sites as $ site ) { if ( is_user_member_of_blog ( $ userId , $ site -> blog_id ) === true ) { continue ; } add_user_to_blog ( $ site -> blog_id , $ userId , $ role ) ; } } elseif ( is_user_member_of_blog ( $ userId , get_current_blog_id ( ) ) !== true ) { add_user_to_blog ( get_current_blog_id ( ) , $ userId , $ role ) ; } } else { if ( isset ( get_userdata ( $ userId ) -> roles ) && ! empty ( get_userdata ( $ userId ) -> roles ) ) { return false ; } wp_update_user ( array ( 'ID' => $ userId , 'role' => $ this -> defaultRole ) ) ; } }
Update role, if account is newly created. If is multiste, assign to all sites.
@param int $userId The user id to assign default role to.
@return bool
Update role if account is newly created . If is multiste assign to all sites .