Gdn_Plugin::getUserMeta PHP Method

getUserMeta() protected method

This method takes a $UserID or array of $UserIDs, and a $Key. It converts the $Key to fully qualified format and then queries for the associated value(s). $Key can contain SQL wildcards, in which case multiple results can be returned. If $UserID is an array, the return value will be a multi dimensional array with the first axis containing UserIDs and the second containing fully qualified UserMetaKeys, associated with their values. If $UserID is a scalar, the return value will be a single dimensional array of $UserMetaKey => $Value pairs.
protected getUserMeta ( integer | array $userID, string $key, mixed $default = null, boolean $autoUnfold = false ) : array
$userID integer | array The UserID or array of UserIDs.
$key string The relative user meta key.
$default mixed An optional default return value if key is not found.
$autoUnfold boolean Automatically return key item for single key queries.
return array Return the results or $Default.
    protected function getUserMeta($userID, $key, $default = null, $autoUnfold = false)
    {
        $metaKey = $this->makeMetaKey($key);
        $R = $this->userMetaModel()->getUserMeta($userID, $metaKey, $default);
        if ($autoUnfold) {
            $R = val($metaKey, $R, $default);
        }
        return $R;
    }