Domanda

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!

È stato utile?

Soluzione

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;
  }
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top