0

I am formatting the user profile page in Drupal 8.9.2.

Are tokens available for the user being viewed (in user profile page), to display the user information?

I am using the Token and the Token Filter modules for this. (edited: 8:44 AM 10 Sep 20)

13
  • 2
    For example, you're on a user page, e.g. /user/123, and you want to display information about the user with id 123 somewhere on the page via a token?
    – sonfd
    Sep 9, 2020 at 12:26
  • @sonfd: Exactly. For example consider a user field First Name, when I use the token available for user, in my case [user:field_fir] it does not work. I can see that it requires context but I am unable to find how to do it. Sep 10, 2020 at 0:38
  • @sonfd Can you help me? Sep 11, 2020 at 12:07
  • You seem to have the format correct, it should be something like [user:field_custom]. Ca you please update your question with more information around how you're using these tokens. Where are you placing them? Do other tokens work in the same place?
    – sonfd
    Sep 11, 2020 at 12:25
  • @sonfd I have created some user fields. Two of them are- (1) Qualifications (2) Registration no. Then, I created a custom block with token values. Qualifications: [user:field_qualifications] Text value: [user:field_qualifications:value] Registration no.: [user:field_registration_no_] Text value: [user:field_registration_no_:value] Then, I went to Configuration > People > Account settings > Manage Display > User Account > Manage Layout Then, I placed this custom block in a column. But, this is not working. Sep 11, 2020 at 12:51

1 Answer 1

0

I have solved the problem this way.
(1) I created a View to show desired user information.
(2) Then, I added a 'Contextual filter' to point to the user being viewed. (with the options "User ID > Provide default value > Type: User ID from route context")
(3) Then, I selected 'REWRITE RESULTS' and "Override the output of this field with custom text". As a result replacement tokens become available for user fields. I used that for formatting the Information according to the requirement.
Then, I placed this View block at the desired place.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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