Form alter in a custom module I am trying to modify a form with a hook_form_FORM_ID_alter within a module though it doesn t seem to have any effect at all when called from within my module. 

My code looks like something like this: 

function fb_reg_form_user_register_form_alter(&amp;$form, &amp;$form_state, $form_id ){ 
    $form['field_lang_list']['#prefix'] = '&lt;div style="display:none;"&gt;';
    $form['field_lang_list']['#suffix'] = '&lt;/div&gt;';

   $fbu = fb_facebook_user();
   if ($fbu || is_numeric($fbu)){
   $fb_account = fb_api($fbu);

   krumo($fb_account);
   $form['account']['mail']['#prefix']= '&lt;fb:profile-pic uid="'.$fbu.'" linked="false"&gt;&lt;/fb:profile-pic&gt;';
    $form['account']['mail']['#default_value'] = $fb_account['email'];
    $form['account']['name']['#default_value'] = $fb_account['name'];
    //$form['account']['name']['#default_value'] = $fb_account['name'];
   }
}


The thing i don't understand is that this works as expected when the hook is called from within the template.php but when in the module it self i can't seem to get it work. 

Would anyone have any idea on what s going on?

EDIT: Could this have something to do module weight ?

Many thanks,
If the part of the form you're altering doesn't exist when you're altering it (if it's put there by some other form-altering module) OR if some other module is altering the form after you and wiping out what you're doing then you can indeed have a module weight problem. The way to find out is to put a dsm() (see devel module) in your code and see what the form looks like before your alter. Or use a debugger of course (recommended!)