Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

147
Views
How to pass User First Name & ID in a Javascript tag in WordPress Backend?

I am trying to connect usetiful to my WordPress Backend.

I need to tag the users and pass information to Usetiful for further personalization.

After going through various similar Q/A threads, I managed to retrieve and pass the User ID to Usetiful, but having trouble getting the User First Name.

Here is the Code Snippet that I am using (Adding code to the Code Snippets Plugin)

<script>
window.usetifulTags = { userId : <?=get_current_user_id() ?>, firstName : <? $user_info = get_userdata(get_current_user_id());$first_name = $user_info->first_name;return $first_name;?>;};

The get_current_user_id() works well, but unable to get the User First Name/Display Name

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Since this is a text, you need to wrap some quotes around it and you should make sure your PHP is a proper value to be evaluated. If you have more operations to be performed, then it is to be recommended to implement a function and only call the function.

<script>
window.usetifulTags = { userId : <?=get_current_user_id() ?>, firstName : "<? $first_name = get_userdata(get_current_user_id())->first_name ?>"};
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!