How to alter the languages available in a form I have a multilanguage site. When I go to edit a node, all the languages of the site are available. I only want some of the active languages to appear in the dropdown for certain users (for various complicated reasons).

In Drupal 6 I did this:

function example_form_alter(&amp;$form, &amp;$form_state) {
    //example_language_list returns an array in the from of   ("en"=&gt;"English") etc
    $languages = example_language_list($form['#node'], TRUE);
    $form['language']['#options'] = $languages;
    if (count($languages)==1) {
        $form['language']['#disabled'] = TRUE;
    }
}


Any idea how I do this in Drupal 7?
OK: found the answer for anyone else. In D7, the i18n implements a callback that happens AFTER the form is rendered, so you need to add a callback as well. So:

function example_form_node_form_alter(&amp;$form, $form_state) {
   $form['#after_build'][] = '_example_form_node_form_alter';
}

function _example_form_node_form_alter($form, &amp;$form_state) {
  //example_language_list returns an array in the form of ("en"=&gt;"English") etc
  $form['language']['#options'] = example_language_list($form['#node'], TRUE);
  if (!i18n_node_language_options($node, 'required')) {
    $form['language']['#options'] = array(LANGUAGE_NONE =&gt; t('Language neutral')) + $form['language']['#options'];
  }
 return $form;
}