Hi: I have a question that I hope is not too dumb. I want to have a situation where if I grant a user access to role A he gets a specific email (email A) while if I grant him role B he gets a different email (email B).

I thought I would be able to do this using this module plus the Rules module. I know this module creates a trigger, but I cannot seem to get it to create what the Rules module calls an event. Thus I cannot figure out how to trigger a specific Rule.

I can see how to use triggers and actions. However I can use a trigger to send an email whenever any role is granted. But I cannot see how to add the conditionality to only send the email when a specific role is granted. Rules takes care of this but I do not believe actions/triggers does.

Questions:
1. Is this module integrated with Rules module, and if so, how do I cause an event to be created that will fire a Rule?
2. Is there a way to accomplish my use case with actions/triggers?

Comments

rfay’s picture

This module allows you to take an action *when a role changes*. If I read your question correctly, you're trying to *change a role* when something else happens, which is a different thing. You should be able to do what you want with rules, but you'll need a trigger on the "email arrival" or whatever it is.

To answer your other questions, Rules does triggers and actions, so this should work fine, although I usually just test the base trigger/action functionality.

entrepreneur27’s picture

Actually I think you misunderstand my use case. As I say in the first paragraph, I want to send a different email when I grant my user role A than I send if I grant him role B.

Both of these are actions "when a role changes".

There seems to be some confusion about terminology. The Rules module initiates a rule upon an "event". This is what you call a trigger, and what is called a trigger in core, if I understand correctly.

But as far as I can see this module does not create a "trigger" that the Rules module can use (ie a Rules "event").

You say this module creates a trigger in Rules, but I question whether it does. If it works with "Rules" can you explain where in Rules I view the trigger that says "a role changed"?

rfay’s picture

Issue tags: +rules integration

Looking into this...

rfay’s picture

Title: Rules integration » No current support for Rules module, just triggers
Status: Active » Fixed

Per http://drupal.org/node/312588, it looks like rules supports actions that it finds, but not core triggers.

Unfortunately, I don't know how you would send a different email per role granted with standard actions.

rfay’s picture

I should reference related feature request: #557458: Different Notification Messages for Each Role.

rfay’s picture

Title: No current support for Rules module, just triggers » Implement rules integration
Category: support » feature
Status: Fixed » Active
Juan C’s picture

Subscribe.

dspring0021’s picture

@entrepreneur27, I need to do the exact same thing. It's funny...with all of its functionality, Rules cannot do that (at least that I can tell). This module--Role Change Notify--is a great little module, but I would like to send a different email notification per each individual role, which it does not support. I, too, was optimistic that once I installed Role Change Notify, perhaps Rules would pick it up, but it didn't. :-( I'm trying to think of another way to achieve this functionality. I'm going to take a look at the Role Change Notify module code and see if there are any hacks that I might be able to implement.

There's also Role Watchdog, but I've never used it and can't tell if it will do what we need. Have you? Please let me know if you find a solution for this. Thank you!

teliseo’s picture

Version: 6.x-2.1 » 6.x-2.x-dev
Status: Active » Closed (won't fix)

I see two currently available ways to accomplish the OP’s request. One is a new feature in the current 6.x-2.x-dev of Role Change Notify that triggers for add and remove of individual roles (see #557458: Different Notification Messages for Each Role). This is lightweight and does not require the Rules module. The other is in the current released Rules module version 6.x-1.4 (and probably earlier versions, as well). Using the Rules module to define events when roles change is a built-in feature, and does not require events from a module such as Role Change Notify (the RCN module needn’t even be installed). I tested the following:

  1. Create a rule for the event User account details have been updated.
  2. Add a condition for unchanged user, Negated, and select a single role you want to watch.
  3. Add a condition for updated user (no negation), and select the same role.
  4. Add desired actions (I used Log to watchdog as a test).

This causes an event when a role is added; reversing the negations causes an event when the role is removed. To watch multiple roles in this way, add similar pairs of conditions, ORed with the first, for other roles (another option is to create additional rules). Note that the logic of this does not allow you to select multiple roles in one pair of conditions.

I found a Rules issue, #465250: Can't detect role changes on "User account details have been updated" event, that may be related to the method described above, but in my testing I did not see a problem.

With this built-in functionality of Rules, it would be redundant to add Rules integration to Role Change Notify. This, plus the new individual role triggers, compel me to close this as won't fix.