MrUpsidown
MrUpsidown

Reputation: 22497

Drupal 7 - User profile field editable only at registration

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!

Upvotes: 0

Views: 993

Answers (1)

Rawkode
Rawkode

Reputation: 22592

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;
  }
}

Upvotes: 3

Related Questions