0

I have 2 types of content that are: Videos and Customers.

A video can be related only by 1 customer. I want that when a video is created or edited, will send an email to the customer associated with the video.

"Videos" has a Node_reference that is the customer reference. "Customers" have a user_reference referencing the corresponding user.

Then, using Rules for send mail but I don't know how to get the email of the user from the field node_reference from "Videos" to user_reference of "Customers".

How can I do this?

2
  • Have you added the condition "entity has field", then explicit defined your user ref field? Once you do that, in theory you should be able to drill down to user:mail Commented Aug 19, 2013 at 19:24
  • You can look into the availables tokens on the rules Commented Aug 20, 2013 at 9:14

1 Answer 1

0

In the recipient input, try to write a php code which returns the email :

$customer_node = node_load( $node->field_customer['und'][0]['nid'] ); $account = user_load( $customer_node->field_user['und'][0]['uid'] ); print $account->mail; 

Note that a better way is to use a custom function in a custom module :

print _get_customer_email( $node ); 

and

function _get_customer_email( $node ){ $customer_node = node_load( $node->field_customer['und'][0]['nid'] ); $account = user_load( $customer_node->field_user['und'][0]['uid'] ); return $account->mail; } 
1
  • That is!.. This is the answer! Commented Aug 20, 2013 at 15:04

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.