bb_user_subscribe_checkbox_update

Process subscription checkbox submission.

Description

bb_user_subscribe_checkbox_update( (int) $post_id ); 

Get ID of and new subscription status and pass values to bb_user_subscribe_checkbox_update function

Parameters (1)

0. $post_id (int)
ID of new/edited post

Usage

  1. if ( !function_exists( 'bb_user_subscribe_checkbox_update' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/functions.bb-posts.php'; 
  3.  
  4. // ID of new/edited post 
  5. $post_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bb_user_subscribe_checkbox_update($post_id); 
  9.  

Defined (1)

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

/bp-forums/bbpress/bb-includes/functions.bb-posts.php  
  1. function bb_user_subscribe_checkbox_update( $post_id ) { 
  2. if ( !bb_is_user_logged_in() ) 
  3. return false; 
  4.  
  5. $post = bb_get_post( $post_id ); 
  6. $topic_id = (int) $post->topic_id; 
  7. $subscribed = bb_is_user_subscribed( array( 'topic_id' => $topic_id, 'user_id' => $post->poster_id ) ) ? true : false; 
  8. $check = $_REQUEST['subscription_checkbox']; 
  9.  
  10. do_action( 'bb_user_subscribe_checkbox_update', $post_id, $topic_id, $subscribe, $check ); 
  11.  
  12. if ( 'subscribe' == $check && !$subscribed ) 
  13. bb_subscription_management( $topic_id, 'add' ); 
  14. elseif ( !$check && $subscribed ) 
  15. bb_subscription_management( $topic_id, 'remove' ); 
  16.