3

I have fields added to Drupal 7 core users (Config > People > Account settings > Manage fields) which are common to multiple user roles.

I also have fields on a Profile2 profile, which I only want to display for people registering for that role.

I cannot find a way to show the core user registration fields before the Profile2 fields. Tried Manage Fields and Display Suite, but unless you show the Profile2 fields on ALL user registration forms (which of course I don't want to do, as these fields are only relevant to one role on the Drupal site) I can't reorder them.

Been looking for a solution for over a year. Profile2 project on Drupal.org won't answer, Profile2 Reg Path project on Drupal.org won't answer either. Totally stuck, and very surprised that I seem to be the only one with this issue. I have this issue on multiple sites now.

2

You can use the hook_form_alter() to alter the form and change the weight attribute, if your field is field_username you can use something like this:

function YOUR_MODULE_NAME_form_alter(&$form, &$form_state, $form_id) {

  if($form_id == 'YOUR_FORM_ID') {

    $form['field_username']['#weight'] = -50;
    $form['field_email']['#weight'] = -49;
  }
}
1

Checkout this thread - https://www.drupal.org/project/profile2_regpath/issues/2502261#comment-12892275. Essentially:

My user fields (such as "email" and "username/password") suddenly dropped below several Profile2 fields on the registration page. MY fix:

  1. Go to /admin/config/people/accounts/fields.
  2. Click "Show row weights" above and to the right of the fields.
  3. I then gave Email and Username/Password a weight of -999 and -998, respectively. They then moved to the top of the list on the registration page, since they have the lowest numbers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.