Hi,
I've been struggling with this for some time, but I can't seem to find the solution.
I am trying to get Rules to check the value(s) selected from a taxonomy and, based on this, assign the node to an Organic Group. As both taxonomy and OG have rules integration, this should be possible.
My rule uses some PHP to check if a taxonomy has been selected. The taxonomy is set to allow multiple selections. The PHP is:
return isset($node->taxonomy[1])
If this returns TRUE, then the node is assigned to a selected Organic Group.
My problem is that my PHP is always returning true (even if $node->taxonomy[1] is not set). This means that the Group always gets assigned.
Can anyone suggest a way of doing this?
The export of the Rule is:
array (
'rules' =>
array (
'rules_2' =>
array (
'#type' => 'rule',
'#set' => 'event_node_presave',
'#label' => 'Apply Stage 1 Group Taxonomy',
'#active' => 1,
'#weight' => '0',
'#categories' =>
array (
0 => 'og',
),
'#status' => 'custom',
'#conditions' =>
array (
0 =>
array (
'#weight' => 0,
'#info' =>
array (
'label' => 'Created content is Calendar Event',
'arguments' =>
array (
'node' =>
array (
'type' => 'node',
'label' => 'Content',
),
),
'module' => 'Node',
),
'#name' => 'rules_condition_content_is_type',
'#settings' =>
array (
'type' =>
array (
'calevent' => 'calevent',
),
'#argument map' =>
array (
'node' => 'node',
),
),
'#type' => 'condition',
),
1 =>
array (
'#weight' => 0,
'#type' => 'condition',
'#settings' =>
array (
'code' => 'return isset($node->taxonomy[1]);',
'vars' =>
array (
0 => 'node',
),
),
'#name' => 'rules_condition_custom_php',
'#info' =>
array (
'label' => 'Execute custom PHP code',
'module' => 'PHP',
'eval input' =>
array (
0 => 'code',
),
),
),
),
'#actions' =>
array (
1 =>
array (
'#weight' => 0,
'#info' =>
array (
'module' => 'Organic groups',
'arguments' =>
array (
'node' =>
array (
'label' => 'Content',
'type' => 'node',
),
),
'label' => 'Add content to the specified groups',
'base' => 'rules_core_action_execute',
'action_name' => 'og_add_group_action',
'configurable' => true,
),
'#name' => 'rules_core_og_add_group_action',
'#settings' =>
array (
'groups' =>
array (
2 => '2',
),
'#argument map' =>
array (
'node' => 'node',
),
),
'#type' => 'action',
),
),
'#version' => 6003,
),
),
)
Comments
Same goal
Dear gmak,
We are trying to accomplish the same thing with 'rules' but it doesn't work.
Even setting a seperate CCK field with a value in a node doesn't work.
Did you make any progress so far in getting a solution?
Looking forward,
Marco