user metadata in json format, update the data partly only

You cannot use update_user_meta on its own here. You would need to get_user_meta first, decode your json into an array, update the last_seen element of the array, re-encode it and only then update_user_meta. Unless there is a good reason not to, I would consider just saving these as serialized data (to avoid the json step), … Read more

Populating ACF Image Fields from JSON file

Yes it is possible to populates an acf gallery field from json data. Lets say this is your gallery json from your app… { “gallery” : [ “https://i.imgur.com/VHkyr8P.jpeg”, “https://i.imgur.com/obdqDwa.jpeg”, “https://i.imgur.com/eQuSNVx.jpeg”, “https://i.imgur.com/1lVyIJt.jpeg”, “https://i.imgur.com/5uIOviX.jpeg” ] } Now in your cron job you could run a function as shown below to handle acf gallery field image updates. My … Read more

Automatically import content to wordpress from a json file

You can use wp_insert_post() to add a new post programmatically. For Example, $my_post = array( ‘post_title’ => wp_strip_all_tags( $json->title ), ‘post_content’ => $json->body, ‘post_status’ => ‘publish’, ‘post_author’ => 1, ‘post_category’ => $json->categories ); // Insert the post into the database wp_insert_post( $my_post ); Your link has expired so I could not see the structure of … Read more

pass complex json as shortcode parameter

Maybe there is a better solution, but serialize seems to do the job. Instead of json I could pass json_decoded and then serialized parameters. For example $jsonval = json_decode(‘{“foo”: “bar”}’); $serialized = serialize($jsonval); Shortcode will be something like: [myshortcode parameters=”O:8:”stdClass”:1:{s:8:”foo”;s:3:”bar”;}”] At this point I can handle parameters unserializing them: function myshortcodehandler($atts){ $arrparameters = (array) unserialize($atts[“parameters”]); … Read more