Create a new user using WP REST API and declare meta object

Just found the solution in another question of Stack Overflow. Using the function register_meta(): register_meta(‘user’, ‘icq’, array( “type” => “string”, “show_in_rest” => true )); Now I can make a request using: { “username” : “johndoe”, “email”: “[email protected]”, “password”: “qwerty”, “meta”: { “icq”: “11223344” } } And the response are: { “id”: 49, “username”: “johndoe”, “name”: … Read more

Export all post from database to JSON only when the database gets updated

it’s file_put_contents which saves the data then it have to be in the hook and not in the body of the plugin : function export_posts_in_json () { $args = array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ); $query = new WP_Query( $args ); … $data = json_encode($posts); $folder=”wp-content/themes/bootstrap/library/”; $file_name = date(‘Y-m-d’) . … Read more

WordPress wp-json API – Custom Post Type returns 403

In version 1.1 of the JSON REST API custom post type endpoints have to be registered manually. See: http://wp-api.org/guides/extending.html#registering-your-endpoints In version 2.0 we register endpoints for any custom post types registered with the show_in_rest property set to true. Documentation on how to do this: http://v2.wp-api.org/extending/custom-content-types/#registering-a-custom-post-type-with-rest-api-support

JSON not valid after json_encode posts

Newlines are not valid inside json strings. However you are outputting this code or otherwise checking it for sanity is somehow adding newlines into your long strings here. Check that your strings really are all one line and not broken up into multiple lines.

AJAX returns response 0

Your action hook should be add_action( ‘wp_ajax_cc_author_change_postauthor’, ‘cc_author_change_postauthor_callback’ ); I think because of your wrong hook, your callback function is never called. You might have got this wrong aswell. In your JS code please change your action from cc-author-change-postauthor to cc_author_change_postauthor

Importing JSON feed should the content be sanitized?

There are two aspects here obviously all input should be sanitized JSON is just a wrapper no different then any other type of container which is used to aggregate data for transmission. You almost never sanitize the container as usually in case of an error you will just not be able to extract the data … Read more