Current Node Email field token

Last updated on
28 November 2024

setup token

use the token custom module to create a new custom token with name "nodeemail" of TYPE: custom

and use php filter with following code

if(arg(0)!="node")
return "not viewing a node";

$node = node_load(arg(1));
return $node->field_email['und'][0]['email'];

now wherever you have tokens available you can use [custom:nodeemail]

NOTE1: assuming that email field has machine name field_email and is not translatable ('und') otherwise change accordingly

NOTE2: to get more node fields use echo print_r($node); in the custom token or look at http://drupal.org/node/49768

Who needs this custom token ?

webform 4.x adds support for tokens but if webform is attached to node using "webform block" the tokens are not populating the webform fields as reported in #1544044: Attach webform to node, email to field from node and #1617086: Webform > E-mails: Add "Content values" (ie: node field) support so custom token is needed

This custom token might not be needed after this issue is resolved #919760: Add a [current-page:object:?] dynamic token

Help improve this page

Page status: Not set

You can: