I built a simple math game for my son using javascript so he can practice his math facts.

I want to be able to save and track his high scores using the usermeta table, but I am having trouble figuring it out. I know that I need to use this function:

update_user_meta( get_current_user_id(), 'high_score', $meta_value);

but I cannot determine how to get my "var highScore" from Javascript into the PHP $meta_value. I also need to figure out a hook or something that will trigger the function once the game is over.

edit: I was able to figure it out using the REST API and Ajax. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.