Function to retrieve uLastPasswordChange returns NULL, Other UserInfo properties return fine

Permalink
We have the need to check if the values returned for getUserDateAdded and getUserLastPasswordChange match in order to run some JS (User accounts are created automatically and we want to run certain code if they've logged in but haven't updated certain things in their profile).

getUserDateAdded returns a datetime successfully, but we are unable to retrieve the uLastPasswordChange value. We are using 8.2.1.

$dateCreate = $ui->getUserDateAdded(); //returns proper datetime object
$datePassUpdate = $ui->getUserLastPasswordChange(); //returns null


Thanks in advance for any help!

Studio7
 
MrKDilkington replied on at Permalink Reply
MrKDilkington
Hi Studio7,

You can try this:
$app = \Concrete\Core\Support\Facade\Application::getFacadeApplication();
$userInfo = $app->make(\Concrete\Core\User\UserInfoRepository::class);
// Concrete\Core\User\UserInfo
$user = $userInfo->getByName('R2D2');
// $user = $userInfo->getByID($uID);
// $user = $userInfo->getByEmail($uEmail);
// Concrete\Core\Entity\User\User
$userEntity = $user->getEntityObject();
// DateTime
$passwordChangeDate = $userEntity->getUserLastPasswordChange();
echo $passwordChangeDate->getTimestamp();