1

The following snippet changes the label of the username field on the user registration form from 'username' to 'nick-name' (when inserted into the template.php of the theme:

function my_theme_form_user_register_form_alter(&$form, &$form_state, $form_id) {

    $form['account']['name']['#title'] = t('nick-name');

}

To be consistent I'd like to change the label everywhere that it occurs in the system, such as the user settings form... how do I do that!

3

Add the following code at the bottom of the settings.php file:

 $conf['locale_custom_strings_en'][''] = array(
   'username'      => 'nick-name',
 );

As alternative, you can use the String Overrides module.

Provides a quick and easy way to replace any text on the site.

Features

  • Easily replace anything that's passed through t()
  • Locale support, allowing you to override strings in any language
  • Ability to import/export *.po files, for easy migration from the Locale module
  • Note that this is not a replacement to Locale as having thousands of overrides can cause more pain then benefit. Use this only if you need a few easy text changes.
  • Both great answers! Thank you. I'm guessing that placing something in the settings.php is more efficient but the module is easier for clients to maintain.... Either way far better than changing theme templates that may get overwritten on updates. – theTechnaddict Aug 31 '11 at 6:52
  • 2
    Altering the files of a third-party theme/module, or any Drupal core files is never a good idea. It is the beginning of the maintaining nightmare, as all times the theme/module is updated, you need to edit the new revision of the files to introduce again the changes you put. You could alter a form within a custom module, but in this case there is already a module that can be used. – kiamlaluno Aug 31 '11 at 10:07

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.