Question

In Drupal 7, is there a way to display a mandatory field at registration, and make it un-editable after the user has registered?

Thanks in advance!

Was it helpful?

Solution

From the Drupal backend:

  1. Configuration
  2. Account Settings
  3. Manage Fields

From here you can add your new field (Be sure to check the box that asks if this field should be present on user registration form)

Then you'll want to use a hook to disable this field in the user_profile form.\

Code: template.php

function THEME_form_alter(&$form, &$form_state, $form_id) {
  switch($form_id) {
    case 'user_profile_form':
      $form['field_my_field']['#disabled'] = true;
      break;
  }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top