Short story: I've created a custom profile field, profile_email_address. I want this profile field updated with the value of the user's email address when the user registers and whenever he changes his address.

Long story: I'm using Site User List, which displays the e-mail address if desired. Even combining that with Profile Privacy, I can't keep a user's e-mail address private -- unless I actually display a custom profile field that has the same value as the e-mail address. So I need a way to update the custom profile field automatically. (Then I'll use User Read-Only to disallow user changes to that field.)

Any suggestions where to start?

Comments

mrtoner’s picture

Wow! My first attempt at a module actually worked! (Thanks to the folks who wrote the LDAP integration module, which I looked at for their use of hook_user().)

<?php
function copy2profile_user ($type, &$edit, &$user, $category = NULL) {
  switch ($type) {
    case 'after_update':
      global $user;
      $user = user_load(array('uid'=>$user->uid));

      $userinfo = array('profile_email_address' => $user->mail);
      user_save($user, $userinfo);
      
      return $user;
  }
}
?>

The profile field is updated just fine. The only problem I have here is that I get a Page Not Found error when it's done. Any suggestions?

mrtoner’s picture

Okay, the real problem is a 500 Internal error, as my logs indicate:

page not found 02/22/2008 - 00:37 500.shtml admin

Once I put in a 500.shtml file, I can see that the issue is this:

REDIRECT_ERROR_NOTES=Premature end of script headers: /home/account_name/public_html/index.php

Not sure where to look now.