Search code examples
drupal-7token

Add token on php page


I need to find the user who is signed on so I can look at his tags. My plan is to write some simple php code in the page, start with the current user, find the contact and look at the tags with SQL. I added the token filter and token insert but the token

[current-user:uid]

is still not replaced.

I have created a basic page in Drupal Added some text and the token. I expected the token to be replaced by my uid but all I see is the token.


Solution

  • Use the following module https://www.drupal.org/project/token_insert. configure it with the field where you are inserting the token.

    Edit :

    You also need to download the token_filter module. Go to the Token UI configure page the link would be "admin/config/content/formats". On that page you will see different text formats viz (Filtered HTML, Full HTML, Plain Text), click on configure link in from of these options.

    Example if you click on Configure for Filtered HTML you would be redirected on the following link "admin/config/content/formats/filtered_html". On this page under Enable filters there is an option which says "Replace Tokens". Check it and save the settings. Insert the token normally in any editor then check the view.