bp_activity_add_meta

Add a piece of activity metadata.

Description

(int|bool) bp_activity_add_meta( (int) $activity_id, (string) $meta_key, (mixed) $meta_value, (bool) $unique = false ); 

Returns (int|bool)

The meta ID on successful update, false on failure.

Parameters (4)

0. $activity_id (int)
ID of the activity item.
1. $meta_key (string)
The meta key.
2. $meta_value (mixed)
The meta value.
3. $unique — Optional. (bool) => false
Whether to enforce a single metadata value for the given key. If true, and the object already has a value for the key, no change will be made. Default: false.

Usage

  1. if ( !function_exists( 'bp_activity_add_meta' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-activity/bp-activity-functions.php'; 
  3.  
  4. // ID of the activity item. 
  5. $activity_id = -1; 
  6.  
  7. // The meta key. 
  8. $meta_key = ''; 
  9.  
  10. // The meta value. 
  11. $meta_value = null; 
  12. $unique = false; 
  13.  
  14. // NOTICE! Understand what this does before running. 
  15. $result = bp_activity_add_meta($activity_id, $meta_key, $meta_value, $unique); 
  16.  

Defined (1)

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

/bp-activity/bp-activity-functions.php  
  1. function bp_activity_add_meta( $activity_id, $meta_key, $meta_value, $unique = false ) { 
  2. $retval = add_metadata( 'activity', $activity_id, $meta_key, $meta_value, $unique ); 
  3.  
  4. return $retval;