update_activity_privacy

Update the privacy.

Description

update_activity_privacy(); 

Usage

  1. if ( !function_exists( 'update_activity_privacy' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress-activity-privacy/includes/bp-activity-privacy-ajax.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = update_activity_privacy(); 
  7.  

Defined (1)

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

/includes/bp-activity-privacy-ajax.php  
  1. function update_activity_privacy() { 
  2. // Bail if not a POST action 
  3. if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) 
  4. return; 
  5.  
  6. global $bp; 
  7.  
  8. // Sanitize the post object 
  9. $activity_id = esc_attr( $_POST['id'] ); 
  10. $visibility = esc_attr( $_POST['visibility'] ); 
  11.  
  12. $is_super_admin = is_super_admin(); 
  13. $bp_displayed_user_id = bp_displayed_user_id(); 
  14. $bp_loggedin_user_id = bp_loggedin_user_id(); 
  15.  
  16. $activity = bp_activity_get_specific( array( 'activity_ids' => $activity_id ) ); 
  17. // single out the activity 
  18. $activity_single = $activity["activities"][0]; 
  19.  
  20. // if is not a activity group  
  21. if ( !isset( $activity_single->item_id ) || ( $activity_single->item_id == 0 ) ) 
  22. else 
  23.  
  24. if( isset( $visibility ) && in_array( $visibility, $levels )  
  25. && ( $is_super_admin || ( $bp_loggedin_user_id == $activity_single->user_id ) ) ) { 
  26.  
  27. bp_activity_update_meta( $activity_id, 'activity-privacy', $visibility ); 
  28. //$visibility = bp_activity_get_meta( $activity_id, 'activity-privacy' ); 
  29. exit;