The invocation of email_confirm in other modules does not seem to fire. For email_change yes, but not for email_confirmation.

So, the following line seems to be completely ignored:

module_invoke_all('email_confirm', 'email confirmation', $account->uid, $account->mail, $new_mail);

A scope issue of some sort? Because when I copy the line to the function invoking the email_confirm hook for email_change, then it works!

Comments

PWG’s picture

bump

jaydub’s picture

Status: Active » Postponed (maintainer needs more info)

Can you show your code that attempts to implement the hook? You should note that the 'email confirmation' operation of the hook will only be fired when a user clicks the email confirmation link in the email sent to their new email address AND all the validation tests pass and their email address is updated. You can look at the function email_confirm_user_change_mail() to see the tests that are applied to the confirmation link when it is clicked to see all the conditions that are checked before changing the user's email.

A quick check on my end implementing a hook works on both the email change and upon successful email confirmation.

PWG’s picture

Hi jaydub! Thanks for responding.

Here is what I do:

1. I change the email address of a user. The email_confirm hook (see below) has been called according to the system log
2. I click the confirmation link in the email sent to the new address. The drupal site opens, stating that the email address has been changed.
3. I check the system log and find the message "User johndoe used one-time e-mail change link at time 1264855579". So all validation tests should have been passed
4. This time, though, the email_confirm hook (see below) has not been executed.

function mymodule_email_confirm($op, $uid, $old_email, $new_email) {
watchdog('mymodule', 'In email confirm: '.$op, null, WATCHDOG_ERROR, l(t('view'), null));
}

Any ideas?

PWG’s picture

Status: Postponed (maintainer needs more info) » Active
jaydub’s picture

hmm I am able to successfully implement the hook in my testing.

Can you edit the module source directly and try to add some debugging?

I don't know the line number in the 6.x-1.4 release as I am looking at the latest in CVS but if you can add some debugging to the email_confirm_user_change_mail() function where you see the call to module_invoke_all() then perhaps we can see whether that code path is being called in your case.

look for this code block:

    else if ($timestamp > $account->login && $timestamp < $current) {
      watchdog('user', 'User %name used one-time e-mail change link at time %timestamp.', array('%name' => $account->name, '%timestamp' => $timestamp));
      user_save($account, array('mail' => $new_mail, 'login' => time()));
      module_invoke_all('email_confirm', 'email confirmation', $account->uid, $account->mail, $new_mail);
      drupal_set_message(t('Your e-mail address is now %mail.', array('%mail' => $new_mail)));
      if ($user->uid) {
        drupal_goto('user/'. $user->uid);
      }
      else {
        drupal_goto('user');
      }
    }

and insert a watchdog() call or error_log or whatever you want to debug before and after the module_invoke_all() call
if it's being called and passed the right values then you'd have to add debugging to your hook implementation.

PWG’s picture

I already did that before I posted this issue. That's when I started to get confused. :)

jaydub’s picture

So what exactly were the results of your debugging? From #6 I can't tell what debugging you did specifically and what results you found...

robby.smith’s picture

subscribing

jaydub’s picture

Status: Active » Postponed (maintainer needs more info)
PWG’s picture

Hi jaydub,

In #5 you suggested to "add some debugging to the email_confirm_user_change_mail() function". I inserted a watchdog before the line

module_invoke_all('email_confirm', 'email confirmation', $account->uid, $account->mail, $new_mail);

The watchdog message was never called. That's when I posted my initial posting #1 and that is what I meant with the line above never firing.

As I never managed to get it to work, I'm not using the email confirmation module. If I'm the only one with this problem, feel free to close this issue.

Thanks!

Petter

PWG’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

I finally figured it out, and it had nothing to do with the module.
I had put the call in a Services module and that is why the hook was never called.