--- email_registration.module	2007-10-17 10:50:51.000000000 +0100
+++ email_registration.module	2007-10-17 11:06:26.000000000 +0100
@@ -30,9 +30,15 @@ function email_registration_user($op, &$
 function email_registration_form_alter($form_id, &$form) {
   switch ($form_id) {
     case 'user_register':
-      $form['name']['#type'] = 'hidden';
-      $form['name']['#value'] = user_password();
-      $form['mail']['#title'] = t('E-mail');
+      if (module_exists('profile')){
+        $form['account']['name']['#type'] = 'hidden';
+        $form['account']['name']['#value'] = user_password();
+        $form['account']['mail']['#title'] = t('E-mail');
+      } else {
+        $form['name']['#type'] = 'hidden';
+        $form['name']['#value'] = user_password();
+        $form['mail']['#title'] = t('E-mail');
+      }
       break;
 
     case 'user_pass':
