Skip to content

Instantly share code, notes, and snippets.

@CaesarOG CaesarOG/userUpdate.js Secret
Created Jan 3, 2017

What would you like to do?
jQuery ajax to update user
jQuery(document).ready(function($) {
$.ajax( {
url: Slug_API_Settings.root + 'wp/v2/users/' + Slug_API_Settings.current_user_id,
method: 'POST',
beforeSend: function ( xhr ) {
xhr.setRequestHeader( 'X-WP-Nonce', Slug_API_Settings.nonce );
//Slug_API_Settings comes from script I enqueued in theme's functions.php which makes some vals available from PHP to the JS
data:JSON.stringify( { roles: ["Free"] } )
} ).done( function ( response ) {
console.log( response );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.