Posted by claudiu.cristea on March 16, 2009 at 9:08am
3 followers
| Project: | Email Change Confirmation |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
How can we let other modules know that we've changed the Email? Do you think that adding a user hook invoke can be a solution?
I'm thinking on a solution (patch) like this in function function email_confirm_user_change_mail(). This is around line 187:
<?php
watchdog('user', t('User %name used one-time e-mail change link at time %timestamp.', array('%name' => $account->name, '%timestamp' => $timestamp)));
db_query("UPDATE {users} SET mail = '%s' WHERE uid = %d", $new_mail, $account->uid);
user_module_invoke('mail_changed', array('new_mail' => $new_mail), $account);
drupal_set_message(t('Your e-mail address is now %mail.', array('%mail' => $new_mail)));
?>This allow a module to invoke the hook in this way:
<?php
function mymodule_user($op, $edit, $account) {
if ($op == 'mail_changed') {
//... perform some tasks... You can use $edit['new_mail']
}
}
?>I need this in a custom module but I want to take an approach that maybe will be included in future releases of the module.
Comments
#1
Here's a patch against 5.x-1.4.
#2
I've added a hook to Email Confirm to allow any module to act on email change requests as well as the successful confirmation of an email change request. This means that any sort of tracking that one would want to do is now possible but I'm leaving the implementation of that tracking open to anyone's particular needs by supplying the hook.
The hook follows this model:
hook_email_confirm($op, $uid, $old_email, $new_email)
Where $op is either 'email change' or 'email confirmation' corresponding to the request to change email address and the confirmation of the email change via clicking the confirmation link in the email sent out as a result of the request to change. The other parameters are self-explanatory.
#3
Thank you. Is this fixed also in 5.x?
#4
yes the hook is implemented the same way in both 5.x and 6.x. I'll put together a new release for both in the next day or two.
#5
Automatically closed -- issue fixed for 2 weeks with no activity.