bp_activity_update_meta

Update a piece of activity meta.

Description

(bool|int) bp_activity_update_meta( (int) $activity_id, (string) $meta_key, (mixed) $meta_value, (string) $prev_value = '' ); 

Returns (bool|int)

Returns false on failure. On successful update of existing metadata, returns true. On successful creation of new metadata, returns the integer ID of the new metadata row.

Parameters (4)

0. $activity_id (int)
ID of the activity item whose metadata is being updated.
1. $meta_key (string)
Key of the metadata being updated.
2. $meta_value (mixed)
Value to be set.
3. $prev_value — Optional. (string) => ''
If specified, only update existing metadata entries with the specified value. Otherwise, update all entries.

Usage

  1. if ( !function_exists( 'bp_activity_update_meta' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-activity/bp-activity-functions.php'; 
  3.  
  4. // ID of the activity item whose metadata is being updated. 
  5. $activity_id = -1; 
  6.  
  7. // Key of the metadata being updated. 
  8. $meta_key = ''; 
  9.  
  10. // Value to be set. 
  11. $meta_value = null; 
  12.  
  13. // Optional. If specified, only update existing metadata entries 
  14. // with the specified value. Otherwise, update all entries. 
  15. $prev_value = ''; 
  16.  
  17. // NOTICE! Understand what this does before running. 
  18. $result = bp_activity_update_meta($activity_id, $meta_key, $meta_value, $prev_value); 
  19.  

Defined (1)

The function is defined in the following location(s).

/bp-activity/bp-activity-functions.php  
  1. function bp_activity_update_meta( $activity_id, $meta_key, $meta_value, $prev_value = '' ) { 
  2. $retval = update_metadata( 'activity', $activity_id, $meta_key, $meta_value, $prev_value ); 
  3.  
  4. return $retval;