bp_add_visibility_to_activity

Add visibility level to user activity meta.

Description

bp_add_visibility_to_activity( ([type]) $content, ([type]) $user_id, ([type]) $activity_id ); 

Parameters (3)

0. $content ([type])
[description]
1. $user_id ([type])
[description]
2. $activity_id ([type])
The activity id.

Usage

  1. if ( !function_exists( 'bp_add_visibility_to_activity' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress-activity-privacy/includes/bp-activity-privacy-actions.php'; 
  3.  
  4. // [description] 
  5. $content = null; 
  6.  
  7. // [description] 
  8. $user_id = null; 
  9.  
  10. // The activity id. 
  11. $activity_id = null; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = bp_add_visibility_to_activity($content, $user_id, $activity_id); 
  15.  

Defined (1)

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

/includes/bp-activity-privacy-actions.php  
  1. function bp_add_visibility_to_activity( $content, $user_id, $activity_id ) { 
  2. $visibility = 'public'; 
  3.  
  4. /** 
  5. if ( !empty( $_POST['cookie'] ) ) 
  6. $_BP_COOKIE = wp_parse_args( str_replace( '; ', '&', urldecode( $_POST['cookie'] ) ) ); 
  7. else 
  8. $_BP_COOKIE = &$_COOKIE; 
  9.  
  10. $visibility = $_BP_COOKIE['bp-visibility']; 
  11. */ 
  12.  
  13.  
  14. if( isset( $_POST['visibility'] ) && in_array( esc_attr( $_POST['visibility'] ), $levels ) ) 
  15. $visibility = esc_attr($_POST['visibility']); 
  16.  
  17. bp_activity_update_meta( $activity_id, 'activity-privacy', $visibility );