Skip to main content
replaced http://drupal.stackexchange.com/ with https://drupal.stackexchange.com/
Source Link

As per the "site:current-user:field-user-profile-type:X" part of your question (X=0 or 1), it seems that your "User profile type" field is a multi value field. Whereas you're trying to use a Data Comparison rules condition. Sorry to say, but for a multi value field, you should NOT use a "Data Comparison", because that's like trying to compare an array with a single value (which doesn't make sense).

To get your rule to work like you want it to work, you should use these Rules Conditions (in the specified order):

  • Entity has field, for your "User profile type" field, to make it available for subsequent Rules Conditions and/or Rules Actions.
  • List contains item, whereas:
    • the list is also about that same "User profile type" field (since your field allows multiple values, it is also considered as a list).
    • the item you want to check for (if it is contained in the list) is (e.g) "Grant Network user".

With those 2 Rules Conditions, your Rules Actions should be performed as you want it to work. For the sake of (basic) unit testing, just (temporary) add a Rules Action like "Display a Drupal Message" (as the very first Rules Action), with whatever message text (eg: "bingo, Pierre is right ...").

For an example Rule (in rules export format) in which you can see this at work, refer to the answer to "http"https://drupal.stackexchange.com/questions/77976/how-to-check-for-product-taxonomy-term-in-rules-actions-ubercart/218483#218483". In that case it's about a list of taxonomy terms, but the idea is the same.

PS: I'm assuming this question is about D7 ...

As per the "site:current-user:field-user-profile-type:X" part of your question (X=0 or 1), it seems that your "User profile type" field is a multi value field. Whereas you're trying to use a Data Comparison rules condition. Sorry to say, but for a multi value field, you should NOT use a "Data Comparison", because that's like trying to compare an array with a single value (which doesn't make sense).

To get your rule to work like you want it to work, you should use these Rules Conditions (in the specified order):

  • Entity has field, for your "User profile type" field, to make it available for subsequent Rules Conditions and/or Rules Actions.
  • List contains item, whereas:
    • the list is also about that same "User profile type" field (since your field allows multiple values, it is also considered as a list).
    • the item you want to check for (if it is contained in the list) is (e.g) "Grant Network user".

With those 2 Rules Conditions, your Rules Actions should be performed as you want it to work. For the sake of (basic) unit testing, just (temporary) add a Rules Action like "Display a Drupal Message" (as the very first Rules Action), with whatever message text (eg: "bingo, Pierre is right ...").

For an example Rule (in rules export format) in which you can see this at work, refer to the answer to "http://drupal.stackexchange.com/questions/77976/how-to-check-for-product-taxonomy-term-in-rules-actions-ubercart/218483#218483". In that case it's about a list of taxonomy terms, but the idea is the same.

PS: I'm assuming this question is about D7 ...

As per the "site:current-user:field-user-profile-type:X" part of your question (X=0 or 1), it seems that your "User profile type" field is a multi value field. Whereas you're trying to use a Data Comparison rules condition. Sorry to say, but for a multi value field, you should NOT use a "Data Comparison", because that's like trying to compare an array with a single value (which doesn't make sense).

To get your rule to work like you want it to work, you should use these Rules Conditions (in the specified order):

  • Entity has field, for your "User profile type" field, to make it available for subsequent Rules Conditions and/or Rules Actions.
  • List contains item, whereas:
    • the list is also about that same "User profile type" field (since your field allows multiple values, it is also considered as a list).
    • the item you want to check for (if it is contained in the list) is (e.g) "Grant Network user".

With those 2 Rules Conditions, your Rules Actions should be performed as you want it to work. For the sake of (basic) unit testing, just (temporary) add a Rules Action like "Display a Drupal Message" (as the very first Rules Action), with whatever message text (eg: "bingo, Pierre is right ...").

For an example Rule (in rules export format) in which you can see this at work, refer to the answer to "https://drupal.stackexchange.com/questions/77976/how-to-check-for-product-taxonomy-term-in-rules-actions-ubercart/218483#218483". In that case it's about a list of taxonomy terms, but the idea is the same.

PS: I'm assuming this question is about D7 ...

Source Link
Pierre.Vriens
  • 36k
  • 40
  • 50
  • 182

As per the "site:current-user:field-user-profile-type:X" part of your question (X=0 or 1), it seems that your "User profile type" field is a multi value field. Whereas you're trying to use a Data Comparison rules condition. Sorry to say, but for a multi value field, you should NOT use a "Data Comparison", because that's like trying to compare an array with a single value (which doesn't make sense).

To get your rule to work like you want it to work, you should use these Rules Conditions (in the specified order):

  • Entity has field, for your "User profile type" field, to make it available for subsequent Rules Conditions and/or Rules Actions.
  • List contains item, whereas:
    • the list is also about that same "User profile type" field (since your field allows multiple values, it is also considered as a list).
    • the item you want to check for (if it is contained in the list) is (e.g) "Grant Network user".

With those 2 Rules Conditions, your Rules Actions should be performed as you want it to work. For the sake of (basic) unit testing, just (temporary) add a Rules Action like "Display a Drupal Message" (as the very first Rules Action), with whatever message text (eg: "bingo, Pierre is right ...").

For an example Rule (in rules export format) in which you can see this at work, refer to the answer to "http://drupal.stackexchange.com/questions/77976/how-to-check-for-product-taxonomy-term-in-rules-actions-ubercart/218483#218483". In that case it's about a list of taxonomy terms, but the idea is the same.

PS: I'm assuming this question is about D7 ...