I wanted to add an email field to the profile that links to the associated contact form. I thought the easiest way to do this would be to add an email field. Not a problem, works fine.

When a user registers with the site though they have to enter an email address. I thought it would be possible to get the email in the profile to automatically be populated with the registered email so I entered some default php code into the default value box:

global $user;
return array(
  0 => array('email' => $user->mail),
);

This works fine for user 0, but doesn't work for anyone else. Is the code correct? Is there a better way to do this?

Regards,
Nick