on_user_change_email
The on_user_change_email
hook is executed whenever a user's email address is updated.
This hook allows plugins to perform additional actions or validations when an email address change occurs.
DynamicHooks::executeHook('on_user_change_email', false, $oldEmail, $newEmail);
This hook is triggered with the following parameters:
$oldEmail
: (string) The user's current/previous email address before the change.$newEmail
: (string) The user's updated/new email address.
The on_user_change_email
hook is primarily used for:
DynamicHooks::addHook('on_user_change_email', function ($oldEmail, $newEmail) use ($jakdb, $lang) {
// Log the email change
$jakdb->insert('email_change_log', [
'old_email' => $oldEmail,
'new_email' => $newEmail,
'changed_at' => date('Y-m-d H:i:s'),
]);
// Send a notification to the new email
JScms_send_email($jakdb, $newEmail, $mailccaddress, $replyto, $subject, $message, $emailfiles);
}, 'email_change_plugin');