0

I asked this question a few days ago: Send email to all users that are tagged with the same tag a node is when created

I decided to go a different route and use the flag and rules module to associate users with certain terms. If a node is created that includes a taxonomy term that a user has flagged, that user will get an email (the email part I have figured out via rules).

I am trying to use a taxonomy field on the user profile page to let people "sign up for (flag)" terms. I am able to get the terms flagged when a user updates their profile but I can not figure out how to unflag from the choices made on the profile edit page for that vocabulary if the user unchecks a term.

In other words, if a user checks a term "on" (selecting it to subscribe to) while editing their profile, it becomes a flagged term and they will receive notifications. If that user comes back and unchecks that term on their profile it is then "unflagged". I have the former figured out (with the rule posted below) but need help with the unflagging.

Here is my rule so far:

{ "rules_email_user_who_subscribe_to_forums" : {
"LABEL" : "Email User who Subscribe to Forums",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "flag" ],
"ON" : { "user_insert" : [], "user_update" : [] },
"DO" : [
  { "entity_fetch" : {
      "USING" : { "type" : "taxonomy_term", "id" : [ "account:field-category:0:tid" ] },
      "PROVIDE" : { "entity_fetched" : { "entity_fetched" : "Fetched entity" } }
    }
  },
  { "LOOP" : {
      "USING" : { "list" : [ "site:current-user:field-category" ] },
      "ITEM" : { "list_item" : "Current list item" },
      "DO" : [
        { "drupal_message" : { "message" : "[list-item:tid]" } },
        { "flag_flagtaxonomy_term" : {
            "flag" : "forum",
            "taxonomy_term" : [ "list-item" ],
            "flagging_user" : [ "site:current-user" ],
            "permission_check" : "0"
          }
        }
      ]
    }
  }
]

} }

enter image description here

Please let me know how I can be more clear with my question. I have been working long hours and I am out of it.

Drupal 7.65

Rules: 7.x-2.11

Flag 7.x-3.9

  • study rules my friend, once you get it, nothing will stop you. cheers, youtube.com/watch?v=QL1Rp69Lq80&list=PL84B6FFA4F7ACAD57 – pinueve Apr 24 at 16:35
  • the approach i gave you in my other answer is the right way, you have to loop all users either way and your new approach it does not. – pinueve Apr 24 at 16:39
  • I am not sure why I need to loop through all users. The action is on one user. "ON" : { "user_insert" : [], "user_update" : [] }, – jpshayes Apr 24 at 19:44
  • you say "If a node is created that includes a taxonomy term that a user has flagged, that user will get an email", so, how about several users had flaggged that taxonomy? this aproach wont work, yo have to loop all users and see in they had flagged that term. the other question aproach is better. if you are developing in a server, give me admin credentials and i will built your rules, after taht you remove me from your site. – pinueve Apr 24 at 19:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.