2

I have a Drupal 7 site, that uses Rules and Quiz. I have a rule that adds a role after the user takes a specific quiz, which work fine. Here are the details of it:

  • Event

    After updating existing content

  • Conditions

    Content is of type

    Parameter: Contenido: [node], Content types: Cuestionario

    Data comparison

    Parameter: Data to compare: [node:nid], Data value: 1985

  • Actions

    Add user role

    Parameter: Usuario: [site:current-user], Roles: nivel2

Now I want a similar rule but add the new role only if a specific profile field in the user's profile, has specific content. The field is a selection of certain terms of a certain taxonomy.

So, I've cloned the above (working) rule, and added to it a condition. So that this new rule looks like so:

  • Event

    After updating existing content

  • Conditions

    Data comparison

    Parameter: Data to compare: [site:current-user:profile-profile:field-ubicacion, Data value: Provincia de Chaco

    Content is of type

    Parameter: Contenido: [node], Content types: Cuestionario

    Data comparison

    Parameter: Data to compare: [node:nid], Data value: 1985

  • Actions

    Add user role

    Parameter: Usuario: [site:current-user], Roles: nivel2

Now in this case, this new rule won't work. I.e the role is not added.

Why could this be?

2 Answers 2

1

Make sure to add a Rules condition Entity has field (related to your additional field in your first Rules condition). And make sure to add that Entity has field condition BEFORE the condition in which you want to perform that "data to compare".

That's also what is mentioned in the Rules UI when you're adding a "data comparison" condition: somewhere it says "The data selector helps you drill down into the data available to Rules. To make entity fields appear in the data selector, you may have to use the condition 'entity has field' (or 'content is of type')".

For a video tutorial that illustrates the importance of this Entity has field condition, refer to Data types and data selection, especially what is shown between about 13:30 and 17:30 in it.

0

The field is a selection of certain terms of a certain taxonomy.

"Data comparison" is for fields with one value. (Or maybe an exact match of multiple values.. I'm not sure.)

Anyways, use the condition "List contains item" for fields with multiple values. And use a few of them if you need to check for more than one term.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.