public function addDefaultRole($userId, $blogId = null)
    {

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

        //Check that user id is a valid int
        if (!is_numeric($userId)) {
            return false;
        }

        // Single
        if (is_numeric($blogId)) {
            if (is_user_member_of_blog($userId, $blogId) === true) {
                return false;
            }
            add_user_to_blog($blogId, $userId, $role);
            return true;
        }

        // Multiple
        if (is_null($blogId)) {
            foreach (get_sites() as $site) {
                if (is_user_member_of_blog($userId, $site->blog_id) === true) {
                    continue;
                }
                add_user_to_blog($site->blog_id, $userId, $role);
            }
        }

        return true;
    }
public function addDefaultRole($userId, $blogId = null)
    {

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

        //Check that user id is a valid int
        if (!is_numeric($userId)) {
            return false;
        }

        // Single
        if (is_numeric($blogId)) {
            if (is_user_member_of_blog($userId, $blogId) === true) {
                return false;
            }
            add_user_to_blog($blogId, $userId, $role);
            return true;
        }

        // Multiple
        if (is_null($blogId)) {
            foreach (get_sites() as $site) {
                if (is_user_member_of_blog($userId, $site->blog_id) === true) {
                    continue;
                }
                add_user_to_blog($site->blog_id, $userId, $role);
            }
        }

        return true;
    }
public function addDefaultRole ( $ userId , $ blogId = null ) { //Get role (superadmin should always be administrator) if ( is_super_admin ( $ userId ) ) { $ role = "administrator" ; } else { $ role = $ this -> defaultRole ; } //Check that user id is a valid int if ( ! is_numeric ( $ userId ) ) { return false ; } // Single if ( is_numeric ( $ blogId ) ) { if ( is_user_member_of_blog ( $ userId , $ blogId ) === true ) { return false ; } add_user_to_blog ( $ blogId , $ userId , $ role ) ; return true ; } // Multiple if ( is_null ( $ blogId ) ) { foreach ( get_sites ( ) as $ site ) { if ( is_user_member_of_blog ( $ userId , $ site -> blog_id ) === true ) { continue ; } add_user_to_blog ( $ site -> blog_id , $ userId , $ role ) ; } } return true ; }
Adds the specified userid to a specified or all blogs
@param integer $userId User id to add
@param integer $blogId Specific blog_id (leave null for all)
Adds the specified userid to a specified or all blogs