Closed (fixed)
Project:
Token
Version:
7.x-1.0-beta1
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
28 Jan 2011 at 04:19 UTC
Updated:
11 Sep 2016 at 12:21 UTC
Jump to comment: Most recent
Comments
Comment #1
zhgenti commentedSubscribing
need the same feature.
I've found a small work around, but these custom tokens won't appear in the tokens help.
this code adds [author:FIELD_NAME] tokens only. without native user fields like name and email. but you can add it too.
Comment #2
zhgenti commentedHey,
Here is more elegant solution. works just great for me. Hope will help you too.
But tokens still won't be available in the help, when printing it with theme('token_tree') ...
Comment #3
dave reidWhat is the 'author' user account the author of? You should probably be chaining tokens like [status-message:author].
Comment #4
dave reidComment #5
zhgenti commentedYes, author is an account.
Here is another scenario when multiple user instances need to be replaced in the message.
Lets say you want to suggest friend(user of the site) to another user. You need to replace names of three users in the one letter.
we can use aliases like
Comment #6
moonray commentedWould like the answer to this as well.
Comment #7
dave reid1. You cannot give 'current-user' an account object. It doesn't work that way.
2. You have to use hook_token_info() to define more 'user' token types similar to how current-user works. In this case you would define a 'friend' token type in your module's hook_token_info().
Comment #8
dave reidAnswer provided in #7.
Comment #10
rudiedirkx commentedHaving to implement
hook_token_info()is silly. Some messages have 'friend', other messages have 'person', other messages have 'person4' etc etc etc. Some config you have to do during runtime, when callingtoken_replace().Sometimes there is no 1 common denominator, like 'status-message' and other times that common has completely different properties (since it can't always be an entity).
#1920688: Support multiple instances of the same token type in token replacement wants it too, but that's D8 so that's simpler, because entity info (type) is always included.
I created this function:
So you can do:
Unfortunately that requires 3
token_replace()calls, but it's the best I could come up with in 11 minutes.Comment #11
dave reidPlease file as a separate feature request rather than re-opening a long-closed issue.
Comment #12
xaris.tsimpouris commentedI know this is an old one, but I would like to post what I did to help others to a different direction.
What I wanted to do is create two new groups of type user in a custom module (referrer/recipient) in order to create customised emails between two accounts for a new invitations system. This is what I came up with.
With the above idea, I have fully capable new groups, that are shown in the token list and work as expected.
Hope it helps.