9

I would like to revise the default new user registration form in Drupal 7. Rather than to requst "username", I want to request "full name" with helper instructions to enter the text "username is your full name as you would normally use it."

There may be some other minor formatting changes I would like to make as well.

I cannot find an admin menu item to access anything relating to this question. And I am unable to locate a file within any director that has any text that would indicate it is the source for the new user registration form.

I realize this is a bit unconventional, however it is useful for our needs. I am aware of a module that allows the input of First Name / Last Name, but in processing it changes the input to first initial/lastname, ie Tom Thumb = username of "tthumb". The module "Realname Registration" would be just what I am looking for if it would only translate the username the same as the input.

That wouldn't necessarily solve the other formatting edits, but I would be very happy just to be able to manually edit the registration form help text under the username field, instructing the new user to register using thier real name.

Thanks for any help that you can provide.

J.M.

13

The easiest way is to create a custom module and use hook_form_alter():

function mymodule_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id === 'user_register_form') {
    $form['account']['name']['#title'] = t('Full name');
    // perform other changes here
    // var_dump() or krumo() the contents of $form to see what you can change
  }
}

If you prefer you can also a variation of hook_form_alter to target the form specifically instead of having to do an if

function mymodule_form_user_register_form_alter(&$form, &$form_state, $form_id) {
  $form['account']['name']['#title'] = t('Full name');
  // perform other changes here
}
  • How can i set the Password field value? i can't find the structure – xstean Nov 20 '15 at 15:49
  • The form is the same for admin and guest registration. To detect whether it is admin "Create user" form or registration form you can use user_is_anonymous(). – milkovsky Jan 19 '16 at 10:55

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.