How to post an unserialized array via wordpress rest API as meta data

So I found my own answer, fave_property_images is not supposed to be an array, its just multiple strings. Therefore the following codes in function.php fixes the problem. function add_fave_property_images() { register_rest_field(‘property’, ‘fave_property_images’, array( ‘get_callback’ => ‘get_property_images’, ‘update_callback’ => ‘update_property_images’, ) ); } function get_property_images( $object ) { //return the post meta return get_post_meta( $object[‘id’], ‘fave_property_images’, … Read more

What is the meta field in the response of the user REST API?

Look into register_rest_field() to register meta with the rest api. add_action( ‘rest_api_init’, ‘adding_user_meta_rest’ ); function adding_user_meta_rest() { register_rest_field( ‘user’, ‘collapsed_widgets’, array( ‘get_callback’ => ‘user_meta_callback’, ‘update_callback’ => null, ‘schema’ => null, ) ); } And then put your get_user_meta bit in the callback. function user_meta_callback( $user, $field_name, $request) { return get_user_meta( $user[ ‘id’ ], $field_name, true … Read more

Cannot DIsplay a Snackbar Notice on Button Click – Notice is undefined

I figured it out. The component was not rerendering, when clicking the “Save” button. I included the compose component in the render method and all is working good now: const Notices = ({ notices, removeNotice }) => { const snackbarNotices = notices ? notices.filter((notice) => notice.type === ‘snackbar’) : []; return ( <> <SnackbarList className=”cwg-admin-notices” … Read more