• Hi, I’m sending a jquery $.post function to a php script on my server. The post is going through fine and I can echo back a response of my posted values. However in my php I want to use these values to update user meta, so I’m sending the user id and the meta (the level they have reached in my game) and running these in update_user_meta like this:

    update_user_meta( $_POST['user_id'], 'level', $_POST['level']);

    But it creates an internal server error 500.

    Any advise as to why this might be/ what i’m missing would be great!

    Thanks,

    Jim

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

    (@bcworkz)

    In order to use WP functions you need to POST your AJAX data to wp-admin/admin-ajax.php with an ‘action’ key value set to an arbitrary string. To access your script, place it in a callback function and hook it to the action 'wp_ajax_' . $_REQUEST['action'] for logged in users and 'wp_ajax_nopriv_' . $_REQUEST['action'] for non-logged in.

    Thread Starter jimme595

    (@jimme595)

    Thank you for the information, much appreciated!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Sending ajax (jquery) post to update user meta’ is closed to new replies.