How do I call an implementation of hook_form_alter()?
hook_form_alter comes in two variants:


hook_form_alter
hook_form_FORM_ID_alter


Both are called when a form is retrieved using drupal_get_form or one of the other form builder functions, but the latter is only invoked for the form with the specific form_id. Unless you are doing the same alterations to multiple forms, it's a good idea to use the hook_form_FORM_ID_alter variation, as it will create less overhead.

All hooks are called by Drupal when certain events happen. For form_alter, that is when the form is being built. So all you need to do, using the example in your question, is to do a check on the $form_id and do the alterations you want.

Notice $form_state should be passed by reference using the &amp;$form_state notation. Sometimes you need to not only change $form but also $form_state to be able to modify the form like you want.