0
votes

I am using Profile 2 to add fields in registration form in drupal 7. now i want to show name fields before username and password fields, how can i do it ?

1

1 Answers

1
votes

Edit: I'm sorry, I had misunderstood your question (left my previous answer for history).

Try Profile2 Registration Path. It promises to merge both your account and profile information on a custom path. Use the .htaccessfile to redirect from user/register to the new URL or install one of the various redirect modules.

Afterwards you might want to follow the approach from my previous answer to correct the order:

Use hook_form_alter to set the weights of the fields according to your needs. You can do so by inserting somthing similar to

function yourthemename_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'user_register_form') {
    $form['field_firstname']['#weight'] = -20;
    $form['field_lastname']['#weight'] = -19;
  }
}

in the template.php of your theme.

Be aware that I'am using the build in profile fields instead of Profile2 but it should work the same way. If you're not sure how your profile fields are to be accessed download and enable develmodule, set permissions to allow guests to access developer information and insert a dpm($form)in the above function.