I'm writing a custom function to now allow spaces and other special characters for the username on the registration form.

How can I remove the text "Spaces are allowed; punctuation is not allowed except for periods, hyphens, apostrophes, and underscores." on that page?

1 Answer 1


I figured it out:

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

  if (!($form_id == 'user_register_form')) {

  $form['account']['name']['#description'] = 'Username has to be between 5-20 characters long and can only contain letters and numbers.';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.