public function checkEmailChange()
{
// check if user didn't change email
if ($this->email == $this->getOldAttribute("email")) {
return false;
}
// check if we need to confirm email change
if (!$this->module->emailChangeConfirmation) {
return false;
}
// check if user is removing email address (only valid if Module::$requireEmail = false)
if (!$this->email) {
return false;
}
// update status and email before returning new email
$newEmail = $this->email;
$this->status = static::STATUS_UNCONFIRMED_EMAIL;
$this->email = $this->getOldAttribute("email");
return $newEmail;
}