Title: WP_Sync_Post_Meta_Storage::add_update
Published: May 20, 2026

---

# WP_Sync_Post_Meta_Storage::add_update( string $room, mixed $update ): bool

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wp_sync_post_meta_storage/add_update/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_sync_post_meta_storage/add_update/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_sync_post_meta_storage/add_update/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_sync_post_meta_storage/add_update/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_sync_post_meta_storage/add_update/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_sync_post_meta_storage/add_update/?output_format=md#wp--skip-link--target)

Adds a sync update to a given room.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_sync_post_meta_storage/add_update/?output_format=md#parameters)󠁿

 `$room`stringrequired

Room identifier.

`$update`mixedrequired

Sync update.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_sync_post_meta_storage/add_update/?output_format=md#return)󠁿

 bool True on success, false on failure.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_sync_post_meta_storage/add_update/?output_format=md#source)󠁿

    ```php
    public function add_update( string $room, $update ): bool {
    	global $wpdb;

    	$post_id = $this->get_storage_post_id( $room );
    	if ( null === $post_id ) {
    		return false;
    	}

    	// Use direct database operation to avoid cache invalidation performed by
    	// post meta functions (`wp_cache_set_posts_last_changed()` and direct
    	// `wp_cache_delete()` calls).
    	return (bool) $wpdb->insert(
    		$wpdb->postmeta,
    		array(
    			'post_id'    => $post_id,
    			'meta_key'   => self::SYNC_UPDATE_META_KEY,
    			'meta_value' => wp_json_encode( $update ),
    		),
    		array( '%d', '%s', '%s' )
    	);
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/collaboration/class-wp-sync-post-meta-storage.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/collaboration/class-wp-sync-post-meta-storage.php#L78)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/collaboration/class-wp-sync-post-meta-storage.php#L78-L98)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_sync_post_meta_storage/add_update/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_Sync_Post_Meta_Storage::get_storage_post_id()](https://developer.wordpress.org/reference/classes/wp_sync_post_meta_storage/get_storage_post_id/)`wp-includes/collaboration/class-wp-sync-post-meta-storage.php` |

Gets or creates the storage post for a given room.

  | 
| [wpdb::insert()](https://developer.wordpress.org/reference/classes/wpdb/insert/)`wp-includes/class-wpdb.php` |

Inserts a row into the table.

  | 
| [wp_json_encode()](https://developer.wordpress.org/reference/functions/wp_json_encode/)`wp-includes/functions.php` |

Encodes a variable into JSON, with some confidence checks.

  |

[Show 1 more](https://developer.wordpress.org/reference/classes/wp_sync_post_meta_storage/add_update/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_sync_post_meta_storage/add_update/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_sync_post_meta_storage/add_update/?output_format=md#changelog)󠁿

| Version | Description | 
| [7.0.0](https://developer.wordpress.org/reference/since/7.0.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_sync_post_meta_storage%2Fadd_update%2F)
before being able to contribute a note or feedback.