Closed (fixed)
Project:
Rules
Version:
6.x-1.x-dev
Component:
Rules Engine
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
2 Oct 2009 at 22:46 UTC
Updated:
26 Sep 2010 at 20:11 UTC
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
Comment #1
imatosyan commentedHi,
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 :)
Comment #2
mitchell commentedUsing the php action is not recommended. Both of those variables are available in rules as tokens.
Comment #4
Vote_Sizing_Steve commentedI'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?