public static function onSetUserEmail(User $user, $newEmail, &$result, &$info) { $app = F::app(); $oldEmail = $user->getEmail(); $optionNewEmail = $user->getGlobalAttribute('new_email'); if (empty($optionNewEmail) && $newEmail != $oldEmail || !empty($optionNewEmail) && $newEmail != $optionNewEmail) { $user->setGlobalAttribute('new_email', $newEmail); $user->invalidateEmail(); if ($app->wg->EmailAuthentication) { $userLoginHelper = new UserLoginHelper(); $result = $userLoginHelper->sendReconfirmationEmail($user, $newEmail); if ($result->isGood()) { $info = 'eauth'; } } } elseif ($newEmail != $oldEmail) { // if the address is the same, don't change it $user->setEmail($newEmail); } return true; }