UserModel::getAttribute PHP Method

getAttribute() public method

Get an Attribute from a single user.
public getAttribute ( integer $UserID, string $Attribute, mixed $DefaultValue = false ) : mixed
$UserID integer
$Attribute string
$DefaultValue mixed
return mixed
    public function getAttribute($UserID, $Attribute, $DefaultValue = false)
    {
        $User = $this->getID($UserID, DATASET_TYPE_ARRAY);
        $Result = val($Attribute, $User['Attributes'], $DefaultValue);
        return $Result;
    }

Usage Example

 /**
  * @param UserModel $user
  * @param $key
  * @return bool
  */
 public function saveKey(UserModel $user, $key)
 {
     $model = $this->getNewUserKeyModel();
     $model->userId = $user->getAttribute('id');
     $model->key = $key;
     $model->expires = new DateTime('+ 1 week');
     return $model->save();
 }
All Usage Examples Of UserModel::getAttribute
UserModel