Token access from module Hi I'm trying to replace a Webform email with a token which works from the tpl file like this:

$company_email = token_replace('[node:field-charter-company:field-company-email]', array('node' =&gt; $node));
echo $company_email;


This works fine but when I try to do it from a module it just outputs "[node:field-charter-company:field-company-email]" instead of the contents of the token.

function webform_node_token_form_alter(&amp;$form, $form_state, $form_id, $node) {

        if ($form_id == 'webform_client_form_126') { 
            $company_email = token_replace('[node:field-charter-company:field-company-email]', array('node' =&gt; $node));
            $form['submitted']['company_email']['#value'] = $company_email;
  }
}


I know I'm doing something wrong but kind of lost. Can anyone give me a pointer?
Extra arguments passed to the initial form function will not be passed to the alter - so the 4th parameter of $node in your form alter function isn't available. If you check your logs you'll probably find a related notice.

For any node form (including webform), you should be able to get the node object directly from the form:

$node = $form['#node'];