Hi,

I'm using this module for functionality of referring new users in exchange for userpoints. Referral link works fine. I just have a problem with creating new referal using Rules.

In user fields I added field for refer e-mail and in my rule I'm loading user by e-mail. It provides exact user that is described in this additional field. The result after user registering with this rule is no referral added and in the db log, the error: INSERT of referral data failed.

I checked my queries that are supposed to be executed. Both from referral link and from rules (from referral.module and from referral.rules.inc) look almost the same, so I don't think this should be a problem. Or maybe it is?

Can someone give me some clue or solution to my problem?

Here is my exported rule in case if it helps anything.

{ "rules_create_new_referral_from_registration_field" : {
    "LABEL" : "create new referral from registration field",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "referral" ],
    "ON" : { "user_insert" : [] },
    "IF" : [
      { "NOT data_is_empty" : { "data" : [ "account:field-referral-mail" ] } }
    ],
    "DO" : [
      { "entity_query" : {
          "USING" : {
            "type" : "user",
            "property" : "mail",
            "value" : [ "account:field-referral-mail" ],
            "limit" : "1"
          },
          "PROVIDE" : { "entity_fetched" : { "referral_users_for_loop" : "Users loaded by mail" } }
        }
      },
      { "variable_add" : {
          "USING" : { "type" : "user", "value" : [ "account" ] },
          "PROVIDE" : { "variable_added" : { "referral_target" : "Referral target user" } }
        }
      },
      { "LOOP" : {
          "USING" : { "list" : [ "referral-users-for-loop" ] },
          "ITEM" : { "loop_user" : "User from the loop" },
          "DO" : [
            { "data_set" : { "data" : [ "referral-target" ], "value" : [ "loop-user" ] } }
          ]
        }
      },
      { "new_referral" : {
          "target_user" : [ "referral-target" ],
          "referring_user" : [ "account" ],
          "host" : "main site",
          "uri" : "main uri"
        }
      }
    ]
  }
}

edit:
I also tried setting cookie with target uid in custom module (using hook_user_presave), but it didn't work. It seems that cookie wasn't being set on time to be used in Referral module.

Comments

tomrog’s picture

Issue summary: View changes