Hope the solution is really simple, but I don't know PHP at all.

As field tokens are still not available for Drupal 7, I need to create a custom token to be exposed to the Rules when an entity is fetched.
I have a content type "mynodetype", with a field "field_mynodetype_myfield".

How to write a custom token for this case?

Comments

gaspaio’s picture

I don't know if this will help, but if you need a token that evaluates as the value for a given field, you can create a custom token that depends on the node object (type = node) with code like this :

return $data['node']->fieldX['safe']

You probably want to add some checks :

return isset($data['node']->fieldX) ? $data['node']->fieldX['safe'] : '';

Does this help you ?

gaspaio’s picture

Status: Active » Closed (fixed)