I have implemented a hook_form_user_register_form_alter().

function hook_form_user_register_form_alter($form, $form_state, $form_id) {
  $form['account']['name']['#description'] = 'This is your login name. It will be displayed on the forums and in comments. This is not your billing information. Spaces are allowed; punctuation is not allowed except for periods, hyphens, apostrophes, and underscores.';
  $form['actions']['submit']['#value'] = 'Continue to subscription and payment page.';
  $form['#submit'][] = 'custom_user_register_submit';


When I use the registration page, I get mixed results. First of all, my custom_user_register_submit() function is called when I click the submit button. This is correct.

However, I get no changes to the form elements printed on the user registration page. For example, but button should have custom text. It does not; it uses the default text 'create new account'. Strangely, in the output from my dpm(), the values in those array elements match my custom code! So, it looks like my hook is implemented correctly and the form elements are being changed, but later in the Drupal bootstrap, they are overridden again and brought back to their defaults.

Anybody know a solution?

1 Answer 1


For all Drupal _alter hooks, you need to pass the variables you need to change as references.

In your function, declaration, $form should be &$form. This makes PHP pass a reference of that variable to inside if your function scope, so changes you make to the $form array persist.

So the function declaration should look like this (to alter both variables): hook_form_user_register_form_alter(&$form, &$form_state)


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.