I would like to change the user associated with a registration in Rules but he property is not writeable, any ideas how to achieve this?

Comments

andyh69uk’s picture

Error thrown in Rules:-

The selected data property doesn't support writing.

andyh69uk’s picture

Right OK, so I have worked out that I think we need to hook registration_entity_property_info_alter() but I am not a php programmer and can't really work out how to do it, any help?

dpi’s picture

mradcliffe’s picture

Here's a rule that I'm currently working on to create accounts for anonymous registrations:

{ "rules_create_account_for_anonymous_registration" : {
    "LABEL" : "Create Account for Anonymous Registration",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules", "registration" ],
    "ON" : [ "registration_update" ],
    "IF" : [
      { "data_is" : { "data" : [ "registration:state:name" ], "value" : "complete" } },
      { "NOT data_is_empty" : { "data" : [ "registration:anon-mail" ] } },
      { "NOT entity_exists" : {
          "type" : "user",
          "property" : "mail",
          "value" : [ "registration:anon-mail" ]
        }
      }
    ],
    "DO" : [
      { "entity_create" : {
          "USING" : {
            "type" : "user",
            "param_name" : [ "registration:anon-mail" ],
            "param_mail" : [ "registration:anon-mail" ]
          },
          "PROVIDE" : { "entity_created" : { "new_account" : "New Account" } }
        }
      },
      { "user_unblock" : { "account" : [ "new-account" ] } },
      { "entity_save" : { "data" : [ "new-account" ], "immediate" : 1 } },
      { "data_set" : { "data" : [ "registration:mail" ] } },
      { "data_set" : { "data" : [ "registration:user" ], "value" : [ "new-account" ] } },
      { "entity_save" : { "data" : [ "registration" ] } }
    ]
  }
}
andyh69uk’s picture

Superstar, I wasn't saving and unblocking the user. The only problem now is the author ID, the permissions system won't allow editing or viewing of the registration because it must be checking the author ID which doesn't match the UID

andyh69uk’s picture

I should try things out before posting, I was trying to set the Author ID not the Author, which works just fine

jnorell’s picture

I'm trying to recreate the rule in #4, but it says

Data selector registration:state:name for parameter data is invalid.

. I can use registration:state, which is just a number .. but I'm curious what I'm missing, or what is different with mradcliffe where that would work? (different version of registration maybe?)

seanberto’s picture

Priority: Normal » Minor

Hey folks,

This ticket is sprawling a bit and asking a lot of different rules integration questions - few of which are providing exports of the rules you are testing, nor a list of the module versions that are being used. Consequently, it's hard to address any remaining issues here.

The ER module is developing a pretty large issue queue. Would someone mind refocusing this ticket or closing it out as fixed? I'm not sure what's left to be addressed.

mradcliffe’s picture

Status: Active » Closed (fixed)

The question answered in the OP is fixed in 7.x-1.x branch with #1664218: Deprecate autoloaded entities for Entity Metadata Wrappers.

seanberto’s picture

Thanks!