Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
How do I create a variable from a PHP action?
How do I create a variable from a PHP action?
Comments
Comment #1
dawehnerAre you sure you created an issue against the right project?
Comment #2
ErnestoJaboneta CreditAttribution: ErnestoJaboneta commentedI'm using the "Execute custom PHP Code" action. I'm not sure where that option came from, I assumed it was either Rules or Core's php module. I asked here since it was probably more of a rules question. Maybe I should ask, how do I programmatically create a variable in the middle of a rules execution? Is this possible?
Comment #3
dawehnerYeah but you filled an issue against views ...
Comment #4
mitchell CreditAttribution: mitchell commentedI don't believe this is a documentation issue. See #1223218: PHP Filter: 'Add a variable' text token does not work.
Comment #5
JordiTR CreditAttribution: JordiTR commentedI know this is an old issue but Ernesto was true, I'm facing the same trouble and the issue pointed by mitchell is not a solution.
What if I need to use the "Execute PHP custom code" to make complex calculations with several values that I want assign to another action as grantting points to a user? I can't, because I can use the "Execute PHP custom code" action but it just "executes" there is no option to assign a variable name to the result of the PHP calculation. Or is it possible?
Comment #6
candelas CreditAttribution: candelas commentedsame problem here and i dont find documentation about it...
Comment #7
candelas CreditAttribution: candelas commentedi saw in https://drupal.org/node/1878018#comment-7780267 a solution that was good for me.
Posted by rbrownell on August 21, 2013 at 7:00pm
Not sure if this helps but you can use PHP to generate the output of the "Add a variable" action (for text).
i passed my code in "evaluate php" and then i could use the variable after :)