ElggUser::isAdmin PHP Method

isAdmin() public method

Is this user admin?
public isAdmin ( ) : boolean
return boolean
    public function isAdmin()
    {
        // for backward compatibility we need to pull this directly
        // from the attributes instead of using the magic methods.
        // this can be removed in 1.9
        // return $this->admin == 'yes';
        return $this->attributes['admin'] == 'yes';
    }

Usage Example

/**
 * Unblocks $blocked_user as blocked by $blocking_user.
 *
 * @param ElggUser $blocked_user
 * @param ElggUser $blocking_user
 * @return bool
 */
function block_user(\ElggUser $blocked_user, \ElggUser $blocking_user)
{
    if (!$blocked_user instanceof \ElggUser) {
        return false;
    }
    if ($blocking_user && !$blocking_user instanceof \ElggUser) {
        return false;
    } elseif (!$blocking_user) {
        $blocking_user = elgg_get_logged_in_user_entity();
    }
    // can't block admins
    if ($blocked_user->isAdmin()) {
        return false;
    }
    return add_entity_relationship($blocking_user->getGUID(), 'blocked', $blocked_user->getGUID());
}