I wanted to set a password as an action in rules. After a lot of testing i found out that there is no data selector available to rules. All available data is followed by a ":"... no matter what i use as event or condition.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

uayebforever’s picture

Status: Active » Needs review
FileSize
514 bytes

The attached patch changes the data type to "text" instead of "string", which allows the user to enter text as expected (rather than requiring a data selector).

However, I'm not sure that the corresponding password is being saved, may be an effect of the test set up I'm using, though.

3rd_rail’s picture

That's a nice workaround for setting up a password at all. Thanks for your help. But my goal was to use the value of a field provided by the saved node as a data selector to set the password for that specific node.

Grimreaper’s picture

Hello,

I just test the patch, it works. And you can select between data selection or direct input with tokens available. So you can use the value of a field provided by the selected node.

Test case :
- add a text field password to content type article
- make a rule :
- event : before saving a content of type (article)
- action : password protect node :
- content : node
- password : select your field value.
- it works.

I paste the export code of the rule :

{ "rules_password_set_automaticaly" : {
"LABEL" : "password set automaticaly",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "protected_node_rules", "rules" ],
"ON" : { "node_presave--article" : { "bundle" : "article" } },
"DO" : [
{ "protected_node_rules_action_password_protect" : { "node" : [ "node" ], "passwd" : [ "node:field-password-for-rule" ] } }
]
}
}

Thanks for the patch.

Grimreaper’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
izus’s picture

Status: Reviewed & tested by the community » Fixed

Merged
Thanks all for the patch and the tests.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.