0

In my D8 site i have several webforms created. I would like to have a Webform element that will pull/prepopulate logged in user's username. Is there a way to achieve that from GUI?

The reason i want that element is that from within Webform Submissions i would like to be able to filter per Username of the user who submitted the webform. This way username will be included in submission data.

By default it allows filtering webform submissions per submission data only or administrative notes.

Thanks

1 Answer 1

6

You can create a Value element with a token to capture and store the current user's name.

name:
 '#title': 'User Name'
 '#type': value
 '#value': '[current-user:name]'

enter image description here

2
  • Thanks @jrockowitz. I will add Token module and give it a try
    – hzak
    Commented Jan 7, 2019 at 22:37
  • It worked perfectly, i did not even have to add token module. Core tokens pulled in the User Name.
    – hzak
    Commented Jan 7, 2019 at 23:20

Your Answer

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

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