• Hello
    I hope I’m in the right forum.
    I know how to get user details using php user id, username etc.. However, I would like to use Javascript to get that information for use inside a lesson created by an authoring system that uses js to get external information. The lesson is then delivered through a wordpress lms (learndash). Do you have any suggestions?

    Thanks for your assistance

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    For the sake of presenting options, what was done before the API was available was to use wp_localize_script() to pass data from PHP to JS.

    Thread Starter mlapl1

    (@mlapl1)

    Thank you @joyously and @bcworkz. I have investigated the API a bit but got a bit confused as I was not quite sure how to code it (at least the docs did not give me the information I thought I needed). I did not use wp_localize although I had heard about it.
    I solved it in the end by connecting from JS to a php file that ran wp_get_current_user function and then reading the response into JS variables. It’s not very elegant or very fast but it works pretty well. I will keep looking for a better solution like the ones you suggested.

    Thanks once again
    Andrew

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Pulling users information using Javascript’ is closed to new replies.