hello,

What is the best practise to trigger 2 different actions depending on the value of a boolean checkbox field on the user account? when checkbox "A" on the profile is checked it fires action a, when it is not checked it fires action b.

more concretely, on the profile page there are 5 checkboxes. if the user checks one checkbox, he gets subscribed to a specific group (using the "fetch entity by ID" action), when he unchecks he gets unsubscribed from the group. unfortunately, boolean checkboxes are necessary (and not a multiple select list which allows for a simpler looping through).

right now i have multiple rules (see screenshot) and components which take two parameter (unchanged, and updated user) and compare the state of each of the checkboxes before and after and triggers the subscription or unsubscription when there was a change. with 5 groups this is quite cumbersome. is there not a smarter way to achieve this?

Ant thoughts?

CommentFileSizeAuthor
adding_rule.png87.16 KBcoreteamvn
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

TR’s picture

Status: Active » Fixed

I guess a smarter way might be to put that logic into a simple module - just a hook_user_update() should do the trick. Rules is a powerful tool, but it's not suited to EVERY task on your website.

TR’s picture

Status: Fixed » Closed (fixed)