2

I got a "flag A". this flag can be flagged with "flag B".

I would like to send an email via the Rules module to the flagging-user of flag A, when flag A has been flagged with flag B.

My problem is I can't find a replacement token for flagging-user of flag A.

I get a lot of tokens for flag a except a token to address the flagging user of flag a.

Available Tokens for Flagged-Flag:

[flagged-flagging:date] 
Flagging date   The date an item was flagged.

[flagged-flagging:flag-freundschaftsspiel-bestaetigen-count]
Freundschaftsspiel bestätigen flag count    Gesamtzahl der Kennzeichnungen für die Kennzeichnung Freundschaftsspiel bestätigen

[flagged-flagging:flag-freundschaftsspiel-bestaetigen-link] 
Freundschaftsspiel bestätigen flag link Flag/unflag link for Freundschaftsspiel bestätigen

[flagged-flagging:original] 
Original flagging   The original flagging data if the flagging is being updated or saved.

[flagged-flagging:field-fs-mannschaft]  
Mannschaft  Feld "field_fs_mannschaft".

[flagged-flagging:field-flag-fs-trikotfarbe]    
Trikotfarbe Feld "field_flag_fs_trikotfarbe".

[flagged-flagging:og-membership]    
OG memberships  A list of all OG memberships of the flagging entity.

[flagged-flagging:og-membership--1] 
Aktiv OG membership A list of all OG memberships of the flagging entity with Aktiv state.

[flagged-flagging:og-membership--2] 
Ausstehend OG membership    A list of all OG memberships of the flagging entity with Ausstehend state.

[flagged-flagging:og-membership--3] 
Gesperrt OG membership  A list of all OG memberships of the flagging entity with Gesperrt state.

[flagged-flagging:field-fs-mannschaft--og-membership]   
OG membership from field Mannschaft A list of all OG memberships registered in field Mannschaft.

[flagged-flagging:field-fs-mannschaft--og-membership--1]    
Aktiv OG memberships from field Mannschaft  A list of all OG memberships with Aktiv registered in field Mannschaft.

[flagged-flagging:field-fs-mannschaft--og-membership--2]    
Ausstehend OG memberships from field Mannschaft A list of all OG memberships with Ausstehend registered in field Mannschaft.

[flagged-flagging:field-fs-mannschaft--og-membership--3]    
Gesperrt OG memberships from field Mannschaft   A list of all OG memberships with Gesperrt registered in field Mannschaft.

[flagged-flagging:flag-freundschaftsspiel-bestaetigen]  
Whether the entity is flagged with flag freundschaftsspiel_bestaetigen  Whether the entity is flagged with flag freundschaftsspiel_bestaetigen.

[flagged-flagging:field_fs_mannschaft]  
Mannschaft  Field Entity Reference.

[flagged-flagging:field_flag_fs_trikotfarbe]    
Trikotfarbe Field Referenz auf Taxonomy-Begriffe.

This is the export of the rule:

{ "rules_freundschaftsspiel_best_tigen" : {
    "LABEL" : "Freundschaftsspiel best\u00e4tigen",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "rules_i18n", "flag" ],
    "ON" : { "flag_flagged_freundschaftsspiel_bestaetigen" : [] },
    "IF" : [
      { "entity_has_field" : { "entity" : [ "flagged-flagging" ], "field" : "field_fs_mannschaft" } }
    ],
    "DO" : [
      { "mail" : {
          "to" : "[flagged-flagging-user:mail]",
          "subject" : "test",
          "message" : "test \r\n[flagging-user:name]",
          "from" : "[site:mail]",
          "language" : [ "flagging-user:language" ]
        }
      }
    ]
  }
}

The token used in the mail action "to" is just an exmaple. There is just no token for the mail of the user of the flagged flag.

The only mail token available is the one of the flagging-user:mail. That would be the flagging-user of flag B.

I guess I would need something like flagged-flagging:flagging-user:mail.

Is there a way I could send an email to the user of flag A that has been flagged by flag B?

The Rule should do as follows:

When a flag ("A" or the same as "Freundschaftsspiel") is flagged by flag "Freundschaftsspiel bestaetigen" then send an email to the user (flagging-user) whos flag has been flagged by "Freundschaftsspiel bestaetigen".

The only condition right now is the one you asked me to add in your first comment. Add a field that is contained in the original flag (Flag A or Freundschaftsspiel).

Freundschaftsspiel is a "friendly game".

The flagged-flagging-user is just a construction of me. It is not found in the replacement patterns.

But some kind like this would be the token a need. As shown above all other data of flag "A" is available, ecept the "author" or flagging-user.

To explain the whole thought behind all this.

A user creates an entity "Freundschaftsspiel" with Date and Team data. All other others that are interested in competing against this team in a friendly match can flag this entity with flag A or "Freundschaftsspiel" flag.

The author of the entity "Freundschaftsspiel" gets a list of interests in a view.

He then flags one of these interests with flag B or "Freundschaftsspiel bestaetigen".

That is when the rule should be fired.

1 Answer 1

1

It's tough to tell what is needed to address your question. But make sure your rule includes a condition that is something like "entity has field", whereas that field is something related to your "flag A". That might make your "flagging user for flag A" available as the token that you're looking for.

Edit 1: after giving it some more thought, and now that the (updated) question also includes the rule you have so far, I think there is something wrong in what you're trying to achieve (or I don't understand it):

  • You want to send an eMail to the "flagging-user of flag A, when flag A has been flagged with flag B."
  • "with flag B" is clearly something any authorized user can do (that's fine).
  • "flag A has been flagged" seems to me like "something" (= flag A) that can be flagged (like with "flag B"). Let's assume (replace) "flag A" for a moment by an entity like a nodes or users (which typically are used for flagging): there is no such thing as "flagging-user" for a node (or user) entity, except if you're talking about flag B. In that case such flagging user indicates the user who has used flag B to flag an entity like a node (or a user).
  • Because of what I explained above, I think you cannot find such "flagging user for flag A", simply because that doesn't exist. That may not be an answer you like to hear, but I'm afraid that is an answer.

Maybe you should try to better explain your usecase first, to check if there is a way to replace your "flag A"-part with some other thing (entity) for which you can then use your existing "flag B"?

Edit 2: Below is an additional attempt to answer your question, based on this part that you added to the end of your question:

A user creates an entity "Freundschaftsspiel" with Date and Team data. All other others that are interested in competing against this team in a friendly match can flag this entity with flag A or "Freundschaftsspiel" flag.

The author of the entity "Freundschaftsspiel" gets a list of interests in a view.

He then flags one of these interests with flag B or "Freundschaftsspiel bestaetigen".

That is when the rule should be fired.

The above confirms what I started to think already ... looks like you're making it too complicated. Forget what is above (in my answer). And keep the "flag A" and the "view" you already have, but get rid of your "Flag B". Just enhance you view by adding the functionality provided by the Rules Link module. Some details about it (from its project page):

This module lets you create links which trigger arbitrary functionality with the help of Rules.

...

The links are usually displayed using Views.

There are three types of links:

  • Javascript - Links that will trigger the rules using Ajax.
  • Token - This are basic links, that will reload the page after calling them.
  • Confirmation link - Show a confirmation form before executing the rule

So instead of "flagging with flag B" (which is clicking a link also, I know ...), the solution is that the link gets clicked that is added via the Rules Link module. To the user (= author of that entity) it will (should!) probably look "similar".

With this (2nd) edit, I'd hope you can you get the rest of your "flagging the flags"-puzzle resolved. Curious to hear how it will turn out.

14
  • Thank you very much for your help. I get all tokens from flag A. But no comparable token as flagging-user:mail.
    – fruitsalad
    Nov 30, 2015 at 23:36
  • Hello. I added an export of my rule to my question. Thank you very much!
    – fruitsalad
    Dec 1, 2015 at 18:23
  • Aha, "now" we are cooking ... it should help to start digesting your question. Give me some time to do so. I "think" that 'flagged-flagging' is what you call "flag A", correct? But by just looking at the exported rule, I'm not sure how to understand/read your rules condition with that 'flag_flagged_freundschaftsspiel_bestaetigen'. Is it something like "if flagged with flag B"? Also, what's the difference between 'flagged-flagging-user' and 'flagging-user' (in your rules condition)? FYI: it may help if you explain these field names used in your rule (via edit of your question). Dec 1, 2015 at 18:49
  • 1
    @fruitsalad is this answer solved your question remember check it as accepted, of you don't know how read this drupal.stackexchange.com/tour Dec 2, 2015 at 15:12
  • 1
    Interesting! I do the same after a few weeks or so. The challenge with that is to "remember which answers to do that for" ... Would be nice if drupal.SE would have a flagging-feature like "wait for feedback" ... one could use "bookmarks" (but that is not what that should be used for I feel). But guess what ... I plan working on something like that soon (also) ... it'll be Drupal based .... Dec 2, 2015 at 15:34

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.