2

What is the hook to alter the form that appears for the URL admin/people/create?

I tried hook_form_alter(), but that's not the right one.

1
  • I think you made a mistake somewhere, I can't think of a reason why hook_form_alter wouldn't work for that particular form. Dec 26, 2011 at 18:45

2 Answers 2

2

/**
 * Implements hook_form_alter().
 */
function mymodule_form_alter(&$form, &$form_state, $form_id) {
  switch($form_id) {
    case "user_register_form" :
      //Your Logic
    break;
  }
}

But for performance issue use hook_form_FORM_ID_alter()

1
  • 2
    For future readers: The implementation of hook_form_FORM_ID_alter() for user_register_form would be hook_form_user_register_form_alter().
    – apaderno
    Jan 8, 2013 at 10:51
1
function modulename_form_user_register_form_alter(&$form) {
  // modify $form var
}

hook_form_FORM_ID_alter() API Docs

1
  • 2
    The complete list of parameters would be &$form, &$form_state, $form_id; if the function is just using the first parameter (as it normally happen), it can short the parameter list to only that parameter.
    – apaderno
    Jan 8, 2013 at 10:53

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.