3

What is the difference between "site:current-user:field-foo" and "account:field-foo" in the Rules "Add a new condition"?

  • It depends on the context of the rule...what event are you responding to? – Clive Oct 15 '12 at 16:31
  • that's "After saving a new user account" – ja_him Oct 15 '12 at 16:35
2

As I mentioned in the comments the variables you have available to you in a rule depend on the context it's in.

[site:current-user] is a global token available to any rule and will always return an object relating to the currently logged in user.

The [account] token is there because you're responding to the "After saving a new user account" event; that event passes an object relating to the user object that has just been saved (for obvious reasons).

I guess the main distinction is that the former will always give the currently logged in user, while the latter could be a different user object altogether (if, for example, an administrator had created the account).

| improve this answer | |
1

In the "After saving a new user account" event, [account:field-foo] is referring to the account being saved, while [site:current-user:field-foo] is referring to the currently logged-in user, which possibly is the user who created the new account, or caused the account to be automatically created.

In the case of an administrator creating an account for another user, [site:current-user:field-foo] would be for the administrator account.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.