retrieving external api data and updating existing custom post

Use the ACF field name, not the field key. This works: update_field(‘forecast_link’, $json_data[‘properties’][‘forecast’], $post_id); update_post_meta($post_id, ‘forecast_link’, $json_data[‘properties’][‘forecast’]); Use array keys to access nested data as needed. Reference (ACF Docs): https://www.advancedcustomfields.com/resources/update_field/

wp_update_post breaks my function

Found the answer thanks to Jacobs comments + this similar thread: I had to use remove_action() WITH matching priority, like this: function booking_meta( $post_id, $post, $update ) { if ( get_post_type( $post_id ) !== ‘booking’ ) { return; } // Update ACF fields $object_id = get_the_ID(); $owner_id = get_the_author_meta( ‘ID’, $post->post_author ); update_field( ‘object’, $object_id, … Read more

Set limitations of wp_update_post()?

It sounds like you’re facing an issue where using wp_update_post() in your function is unintentionally altering additional fields beyond the post_date and post_date_gmt. This can happen because wp_update_post() is designed to handle a complete post update, and it might modify other fields if they are not specified or handled correctly in your update array. To … Read more

BuddyPress Edit activity function good practice

Looking at https://buddypress.trac.wordpress.org/browser/trunk/src/bp-activity/bp-activity-functions.php there’s several functions: Activity Meta I found bp_activity_add_meta, bp_activity_delete_meta and bp_activity_update_meta in that file, e.g. bp_activity_update_meta: // Update activity meta counts. if ( bp_activity_update_meta( $activity_id, ‘favorite_count’, $fav_count ) ) { Activities It looks like these can be updated the same way wp_insert_post can be used to update a post, by calling bp_activity_add … Read more