0

When a visitor registers on my site, I have a set of rules that create several nodes. One of those nodes is a photo gallery.

The rule for the creation of the gallery title, includes the following: [account:name]'s Photo Gallery and that works fine.

But if the user changes his name later on, the name on the photo gallery is not updated.

I have been struggling with the creation of a rule to do just that but I haven't found the option or configuration that allows me to update the node title.

Any help on this would be greatly appreciated.

Thanks. :)

1 Answer 1

1

You could do that with Rules.

  1. Add a new Reaction Rule (e.g: Update user gallery title)
  2. Event: "After updating an existing user account"
  3. Action: "Fetch entity by property":
    • type = node
    • title = [account:name]'s Photo Gallery
  4. Loop over 'list item' and add action
  5. Action: "Set data value": Set list_item item title
  6. Save list_item.

Update: rule export:

{ "rules_update_gallery_title" : {
    "LABEL" : "Update user gallery title",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules" ],
    "ON" : [ "user_update" ],
    "DO" : [
      { "entity_query" : {
          "USING" : {
            "type" : "node",
            "property" : "title",
            "value" : "[account-unchanged:name]\u0027s gallery"
          },
          "PROVIDE" : { "entity_fetched" : { "entity_fetched" : "Fetched entity" } }
        }
      },
      { "LOOP" : {
          "USING" : { "list" : [ "entity-fetched" ] },
          "ITEM" : { "list_item" : "Current list item" },
          "DO" : [
            { "data_set" : {
                "data" : [ "list-item:title" ],
                "value" : "[account:name]\u0027s gallery"
              }
            },
            { "entity_save" : { "data" : [ "list-item" ], "immediate" : 1 } }
          ]
        }
      }
    ]
  }
}
8
  • This looks logical at first sight but the data selectors do not allow the "title=[account:name]'s Photo Gallery" or "Set data value": Update entity_fetched item title." That's for Drupal version 7. Thanks anyway. :)
    – user14666
    Commented Dec 3, 2013 at 2:25
  • @user14666 actually it does work, needed to save rule to get value option for setting title. Also need to loop over entity_fetched as list_item as multiple values can be returned. Note, you can use account-unchanged for original account prior to update. Rules export added. Commented Dec 3, 2013 at 2:34
  • Copy and paste of the above generate the following error message: ntegrity check for the imported configuration failed. Error message: Data selector <em class="placeholder">list-item:title</em> for parameter <em class="placeholder">data</em> is invalid..
    – user14666
    Commented Dec 3, 2013 at 2:54
  • Do I need an additional plugin for this?
    – user14666
    Commented Dec 3, 2013 at 2:54
  • 1
    Works great! The problem was I was entering \u0027 instead of the simple ' (apostrophe.) Thanks a million. :)
    – user14666
    Commented Dec 4, 2013 at 22:20

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.