How to send user data in json format to another server when user register on wordpress site in PHP

Sending and receiving data in JSON format using POST method xhr = new XMLHttpRequest(); var url = “url”; xhr.open(“POST”, url, true); xhr.setRequestHeader(“Content-type”, “application/json”); xhr.onreadystatechange = function () { if (xhr.readyState == 4 && xhr.status == 200) { var json = JSON.parse(xhr.responseText); console.log(json.email + “, ” + json.password) } } var data = JSON.stringify({“email”:”[email protected]”,”password”:”101010″}); xhr.send(data); Sending … Read more

Inserting custom post meta value using WP-REST API

Well, there is a way to update post meta. You have to add the update_callback when registering rest field. See the example below: function rest_api_player_meta() { register_rest_field(‘sp_player’, ‘player_meta’, array( ‘get_callback’ => ‘get_player_meta’, ‘update_callback’ => ‘update_player_meta’, ‘schema’ => null, ) ); } function get_player_meta($object) { $postId = $object[‘id’]; return get_post_meta($postId); } function update_player_meta($meta, $post) { $postId … Read more

Have WordPress generate a JSON of the content

After pondering your question some I am guessing you mean to generate actual physical JSON file in filesystem to use as data source? That would certainly be unorthodox in WP development. Typically in WP you try to minimize disk access, since it is more likely to be a bottleneck in general. Doing file writes is … Read more

Create post using JSON api plugin

I’ve worked on JSON API for a iPhone app development for a WordPress site to post photos but not using JSON API Plugin, But the basic procedure would be: As you need to be logged in to publish your post, the communication is going to be two way 1. Author writes a article as draft … Read more

creating shortcode to pull json array

As per documentation on wp_remote_get() it doesn’t return you just the body of requested resource. Its return will be either the array of data or WP_Error object on failure. The simplest snippet to get to the body would be: $json = wp_remote_retrieve_body( wp_remote_get( $url ) ); PS it’s kinda weird to be doing this in … Read more