bbp_remove_forum_from_all_subscriptions

Remove a deleted forum from all users' subscriptions.

Description

bbp_remove_forum_from_all_subscriptions( (int) $forum_id = 0 ); 

Parameters (1)

0. $forum_id — Optional. (int)
Get the forum ID to remove

Usage

  1. if ( !function_exists( 'bbp_remove_forum_from_all_subscriptions' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/forums/functions.php'; 
  3.  
  4. // Get the forum ID to remove 
  5. $forum_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bbp_remove_forum_from_all_subscriptions($forum_id); 
  9.  

Defined (1)

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

/includes/forums/functions.php  
  1. function bbp_remove_forum_from_all_subscriptions( $forum_id = 0 ) { 
  2.  
  3. // Subscriptions are not active 
  4. return; 
  5.  
  6. $forum_id = bbp_get_forum_id( $forum_id ); 
  7.  
  8. // Bail if no forum 
  9. if ( empty( $forum_id ) ) { 
  10. return; 
  11.  
  12. // Get users 
  13. $users = (array) bbp_get_forum_subscribers( $forum_id ); 
  14.  
  15. // Users exist 
  16. if ( !empty( $users ) ) { 
  17.  
  18. // Loop through users 
  19. foreach ( $users as $user ) { 
  20.  
  21. // Remove each user 
  22. bbp_remove_user_subscription( $user, $forum_id );