I am really confused.

I have a rule
I have specified an action to take
The action is a php action

Can I have access to a variable's array fields? For example $node->uid or $author->uid.

So how do I load the $node if I cannot access it in this way?

I see this on the page but don't understand 'variable' in this context.

PHP code inside of <?php ?> delimiters will be evaluated and replaced by its output. E.g. <? echo 1+1?> will be replaced by 2. Furthermore you can make use of the following variables:
Variable	Type	Description	Intelligent                   saving
$node	content	              saved content	          Yes


Note that variables are passed by reference, so you can change them. If you want to make the changes permanent, you can let rules intelligently save the changes when the variable's data type supports it. To make use of "intelligent saving" just return an array of variables to save, e.g.:
return array("node" => $node);

So variables are saved only once, even if modified multiple times

Any help would be greatly appreciated.

Thanks,
Chris

Comments

imatosyan’s picture

Component: Rules Core » Rules Engine

Hi,

I am new to rules, and I have a similar problem with understanding of possibility of using mentioned variables in php snippet, it does not work.

Back to your question, from php snippet you can access $node->uid or $author->uid , I just tested it.

And a while ago, I found out, that you do not need variables from PHP execution, as you can use tokens in php snippet, which are presented above, so you have whatever you want.

To have more tokes, add action to rule to load what you need.

Hope will help, my first try to help :)

mitchell’s picture

Status: Active » Fixed

Using the php action is not recommended. Both of those variables are available in rules as tokens.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Vote_Sizing_Steve’s picture

I'm able to change the $node->title, but not any cck fields. Should I be able to change cck fields with the passing of $node in a php action, or do I need to use the populate field action?