I'm using LDAP authentication via the LDAP_integration module, but believe it or not, the user's email is not currently part of our LDAP config. I can look it up pretty easily, and I've written the php code to get the email address, but rather than hacking ldapauth.module, I thought I would try to write a separate module.
So I think I want something like:
MyEmail_user($op, &$edit, &$user, $category = NULL) {
switch($op) {
case 'insert':
watchdog('Email', t("Email is getting changed"), WATCHDOG_NOTICE);
// print_r($edit);
$edit[mail][init] = my_email_function($user);
break;
}
}
I'm pretty sure my module is getting called before the new user gets created. So I'm trying to over-ride what would get saved as the user's email. But this isn't working.
From the hook_user page insert is:
The user account is being added. The module should save its custom additions to the user object into the database and set the saved fields to NULL in $edit.
But I don't understand the details here. How can I save my custom additions to the database if the user hasn't been created yet? And aren't all the fields of $edit being saved?