I have created a rule by using php code,i want to import it.When i click on import button it is showing that import block border as red(shown in the fig..)

  1. Image

enter image description here

  1. Code

And my code is shown in below,

{ "rules_send_warning_email" : {
    "LABEL" : "Send Warning Email",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "user_update" : [] },
    "IF" : [
      { "text_matches" : { "text" : [ "site:current-user:field-warnings" ], "match" : "New litter" } }
    "DO" : [
      { "mail" : {
          "to" : "[site:mail]",
          "subject" : "New litter was born",
          "message" : "[site:current-user] selected new litter",
          "language" : [ "" ]

2 Answers 2


Your rule is looking for a field on the user entity type called "field_warnings". That field doesn't exist, or can't be found for whatever reason, so the import will fail.

You need to either add the field, or find out why Drupal can't find it, to continue with the import.

  • It is not user entity type,what can i change in that code .It Is just normal select list field in content. I am suffering a lot for this solve this. feel great!!!!!.
    – DINE
    Commented Sep 9, 2015 at 10:14
  • Yes it is the user entity type; site:current-user is a user entity
    – Clive
    Commented Sep 9, 2015 at 10:16
  • @ Clive-Now what can i do for this.
    – DINE
    Commented Sep 9, 2015 at 10:17
  • What can you do for what?
    – Clive
    Commented Sep 9, 2015 at 10:17
  • @ clive - what can i change in that code.
    – DINE
    Commented Sep 9, 2015 at 10:20

The way you created this rule (using PHP?) seems to me like equivalent to handwriting a rule in Rules export format. Using the Rules UI you can pretty sure not create a rule that, after save and export, looks like your rule you're trying to import.

The reason why you get that "red border around your import block", is because of the *Failed integrity check". And that check failed because in your Rules condition it is impossible (for the Rules module) to find that field_warnings-field, similar to what Clive also mentioned as a possible cause.

The real reason why that field cannot be found (even if it would exist as a field related to the user account), is because before you can actually use it in a Rules condition, you "must make it available" to Rules. The way (or "a" way) to do that, is to insert an extra condition in your Rules condition, in front of the condition you already have, which looks something like so:

{ "entity_is_of_type" : { "entity" : [ "site:current-user" ], "type" : "user" } },

Attention (1): I'm assuming that field is related to an entity "user". If it's another type of entity where that field is related to, then change "user" accordingly. If that still doesn't work, then try with an extra condition that is something about "entity has field".

Attention (2): make sure to correctly differentiate between "user_update" and "current-user":

  • user_update is related to the userid for which the profile is being updated.
  • current-user is the userid actually performing the update.

Refer to my answer to "Which Rules condition can be used to email a user when an admin updates their profile?" for a similar case to illustrate the difference between those 2 variations of user ids.


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.