Posted by greggles on June 21, 2011 at 3:21pm
3 followers
| Project: | Token |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Issue Summary
It would be nice to have one global token for whether the current global user is anonymous or authenticated.
You can kind of get this from the roles token, but then you get all other roles.
This is useful for google analytics custom variables which has token integration.
Comments
#1
How would you expect the token to work? Maybe seeing some sample output of the token would help.
#2
I have the same use case, but with Drupal 6.x. I've created the attached module to create a tokenvalue for ['user']['logged-in'].
Doing this in token_user.inc would require a 2 line patch.
#3
Thanks for your comment and for helping make this a better module. Could you provide this as a patch?
#4
First time with tortoisegit, here's to hoping it works.
Again: I've done my work on the 6.x branch, I haven't looked into 7.x
#5
Looks like a good start. When you upload a patch be sure to set the status to "needs review" so others can find it.
I'm marking it "needs work" because it seems you used a tab for indentation rather than spaces.
I'm not sure whether the use of t() makes sense here. For my purposes it is to track users in google analytics so having different variable values for each user language wouldn't be desired. Perhaps we need two tokens, one that shows a text representation like you have and one that returns a 0 for anonymous and a 1 for authenticated. Thoughts?
#6
I agree that the use of t() doesn't really have purpose. I've scrapped it in the attached patch, as well as change the tabs to spaces.
I don't see much benefit (in google analytics), because most users would just have to think harder: does the '1' represent logged in or anonymous? Perhaps TRUE and FALSE? Do you have a usecase where you need the binary approach? But perhaps that's something for a different issue?
#7
It would be appreciated if someone could take a look at this...