-
-
Save CaesarOG/f75735379fd22548a0723cbff25a7233 to your computer and use it in GitHub Desktop.
jQuery ajax to update user
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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