Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#1 | protected_mode_rules-1926116-1.patch | 514 bytes | uayebforever |
Bildschirmfoto 2013-02-24 um 17.43.26.png | 96.48 KB | 3rd_rail |
Comments
Comment #1
uayebforever CreditAttribution: uayebforever commentedThe 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.
Comment #2
3rd_rail CreditAttribution: 3rd_rail commentedThat'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.
Comment #3
GrimreaperHello,
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.
Comment #4
GrimreaperComment #5
izus CreditAttribution: izus commentedMerged
Thanks all for the patch and the tests.