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 am wanting to create a link an an admin report where the username is as masquerade link in the same way that is is on the in the admin/people/users page
I notice the link isn't straight forward as there is a token.
So How can I do about getting the token so I can create a link?
Comments
Comment #1
wjaspers CreditAttribution: wjaspers commentedShameless plug, as well, but I've already addressed this problem with http://dgo.to/masquerade_extras if you use the Views integration.
Comment #2
wjaspers CreditAttribution: wjaspers commentedUnless there's additional feedback or you have other questions, I think this can be marked as fixed.
Comment #3
chaloum CreditAttribution: chaloum commentedwhat if your not using views integration?
Comment #4
wjaspers CreditAttribution: wjaspers commentedI should have clarified.
The problem of generating a custom link is solved with masquerade_views by generating lists from contextual arguments.
Alternatively, if you need a one-off solution, the above code will work.
Load the user you want in a custom module, and attach the link to the output you want, or in your theme.
Comment #5
chaloum CreditAttribution: chaloum commentedthanks I'll give it a go
Comment #7
chaloum CreditAttribution: chaloum commentedI have tried this but I get the message, Access denied, You are not authorized to access this page.
If I copy the token from the users list it works but If i use the generated token $token = drupal_get_token(); I get the error.
It doesn't seem to like the the token generated by my module
any ideas on how to generate a token that masquerade likes?
Comment #8
wjaspers CreditAttribution: wjaspers commentedOops, I missed a parameter on drupal_get_token().
You need to tell it the path you want to hit (i.e. it should be the same as the "masquerade/switch/###" where ### is the UID you want.
Example:
Comment #9
chaloum CreditAttribution: chaloum commentedThanks after a bit of mucking around I figured it out