I am trying to create a simple block user functionality on my site. I have a "Block/Unblock User" Flag that other users can block and unblock so they stop getting contact emails from (via entityform)

The entityform is set up like (logged in users):

NodeReference: Points to content they are interested in. I use tokens to fill in the authors name, email, etc... 
Message: Text message to email field_nodereference:author:mail

So I am trying to create a rule (using the Rules module):

Event: Before saving a entityform submission

NOT User has roles: entityform-unchanged:user is administrator (admins can bypass rule)

Entity is of bundle: Parameter: Entity: [entityform-unchanged], Entity type: Entityform Submission, Entity bundle: Contact Article Creator

Entity has field: Parameter: Entity: [entityform-unchanged], Field: field_nodereferencearticle

User is flagged
Parameter: Flag: Block/Unblock User, user: [entityform-unchanged:user], User on whose behalf to check: [entityform-unchanged:field_nodereferencearticle:author


Page Redirect to site:url
Show Message: Warning: Was unable to send messsage. The Recipient has blocked you from contacting them. 

So the basic premise of this is if a user blocks another user, this rule will preprocess all Contact Article Creator eforms and see if the potential recipient has blocked the user. If so, redirect to the front page with a warning stating the user blocked them.

EDIT 1: However, every eform I submit goes through. I can't get the rule to not submit.

EDIT 2: Here is the actual exported rule.

{ "rules_block_user_from_sending_message_if_user_blocked_them" : {
"LABEL" : "Block user from sending message if user blocked them",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"TAGS" : [ "entityform", "flag" ],
"REQUIRES" : [ "rules", "flag", "entityform" ],
"ON" : { "entityform_presave" : [] },
"IF" : [
  { "entity_is_of_bundle" : {
      "entity" : [ "entityform-unchanged" ],
      "type" : "entityform",
      "bundle" : { "value" : {
          "contact_seller" : "contact_seller",
          "contact_seller_anonymous" : "contact_seller_anonymous"
  { "entity_has_field" : { "entity" : [ "entityform-unchanged" ], "field" : "field_listing" } },
  { "flag_flagged_user" : {
      "flag" : "block_unblock_user",
      "user" : [ "entityform-unchanged:user" ],
      "flagging_user" : [ "entityform-unchanged:field-listing:author" ]
"DO" : [
  { "redirect" : { "url" : [ "site:url" ] } },
  { "drupal_message" : { "message" : "Was unable to send message. ", "type" : "warning" } }

} }

  • Any feedback about my answer? Commented Aug 29, 2016 at 8:04

1 Answer 1


It seems pretty obvious to me that something in any of your Rules Conditions is not working as you'd expect/want them to work. Which would also explain your "I can't get the rule to not submit".

Basic debugging

You clearly have a combination of Rules Conditions that need some debugging. Rules is great, but sometimes also tough to debug if things don't work as you'd expect. There are some typical facilities to do such debugging, but my Keep-It-Super-Simple technique I often use is my BINGO-trick. A sample of such rule can be found in my answer to "Which Rules condition can be used to email a user when an admin updates their profile?". Stupid, but simple and efficient (I think).

Also, since you have 3 Rules Conditions in a single rule, you should try to see what happens (if you get a "bingo") for each of the individual Rules Conditions. This by simply (temporary) removing 2 out of the 3 Rules Conditions you are using, and verify if they each result in the Rules Action you'd expect (also just a simple Bingo-message should be sufficient).

Advanced debugging

Something else that will help you find the answer to your question, is to have a look at Rules debugging ... Within the Rules settings, experiment a bit with the debugging facilities that come with the rules module. At least have a look at the "Rules Evaluation Log" (to check that the Rules logic being executed, actually matches what you expect that logic to be).

Depending on what the result of that type of debugging is, you may also want to (temporary) enable the Devel module, so that you can (temporary) add a Rules Action like "Display a value" (in your case of your node:comments).

For way more details about these 2 variations, refer to Rules debugging, as explained in the answer to "How can I display the value of a variable inside a condition?".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.