User Account Labels

I wanted to override the username field to say "Drupal.org username".

Modules

Code

The modules didn't work on the field, so this is what I ended up using:

function drupal_contrib_custom_form_user_register_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  if (!empty($form['drupal_org_profiles'])) {
    $form['account']['name']['#title'] = t('drupal.org username');
    unset($form['drupal_org_profiles']);
  }
  if (!empty($form['organization_profiles'])) {
    $form['account']['name']['#title'] = t('Username (drupal.org username if you have one)');
    unset($form['drupal_org_profiles']);
  }
}
Tags