Currently, if a user sets up a Rule to be triggered upon the click of a Button Field, then the variables available to use when designating actions to perform, are only $field_name and $node. For example, if you want to execute some custom php code after the button is clicked, you'll see something like the following, for your options:
------------------------
PHP Evaluation
PHP code inside of
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
$field_name string Field Name No
$node content Node that the button was on Yes
-------------------------
It would be nice to also be able to use the $user variable.
I believe that it can be done by making two quick changes to the code:
1) In the button_field.module file, in the function button_field_callback(), change the following line:
rules_invoke_event('button_field_clicked', $field_name, node_load($nid));
to this one:
rules_invoke_event('button_field_clicked', $field_name, node_load($nid), $user);
2) In the button_field.rules.inc file, add the following code to the function button_field_rules_event_info(), where it is defining the arguments array (it puts "field_name" into the array and then "node" into the array, and then I'd like to see "user" added in):
'user' => array(
'type' => 'user',
'label' => t('Current User')
),
Let me know this actually works, or if there is any problems with doing this. If it could be added to the module, that would be great.
Comments
Comment #1
BassistJimmyJam CreditAttribution: BassistJimmyJam commentedThis has been committed in revision 304468 and will be in the next dev build. Prior to this commit, the $field_name argument was removed as it really wasn't being used properly and the button is evaluation can easily read the GET request.