bb_move_topic

The BuddyPress bb move topic function.

Description

bb_move_topic( $topic_id, $forum_id ); 

Parameters (2)

0. $topic_id
The topic id.
1. $forum_id
The forum id.

Usage

  1. if ( !function_exists( 'bb_move_topic' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/functions.bb-topics.php'; 
  3.  
  4. // The topic id. 
  5. $topic_id = null; 
  6.  
  7. // The forum id. 
  8. $forum_id = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bb_move_topic($topic_id, $forum_id); 
  12.  

Defined (1)

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

/bp-forums/bbpress/bb-includes/functions.bb-topics.php  
  1. function bb_move_topic( $topic_id, $forum_id ) { 
  2. global $bbdb; 
  3. $topic = get_topic( $topic_id ); 
  4. $forum = bb_get_forum( $forum_id ); 
  5. $topic_id = (int) $topic->topic_id; 
  6. $forum_id = (int) $forum->forum_id; 
  7.  
  8. if ( $topic && $forum && $topic->forum_id != $forum_id ) { 
  9. $bbdb->update( $bbdb->posts, compact( 'forum_id' ), compact( 'topic_id' ) ); 
  10. $bbdb->update( $bbdb->topics, compact( 'forum_id' ), compact( 'topic_id' ) ); 
  11. $bbdb->query( $bbdb->prepare( 
  12. "UPDATE $bbdb->forums SET topics = topics + 1, posts = posts + %d WHERE forum_id = %d", $topic->topic_posts, $forum_id 
  13. ) ); 
  14. $bbdb->query( $bbdb->prepare(  
  15. "UPDATE $bbdb->forums SET topics = topics - 1, posts = posts - %d WHERE forum_id = %d", $topic->topic_posts, $topic->forum_id 
  16. ) ); 
  17. wp_cache_flush( 'bb_post' ); 
  18. wp_cache_delete( $topic_id, 'bb_topic' ); 
  19. wp_cache_delete( $forum_id, 'bb_forum' ); 
  20. wp_cache_flush( bb_query ); 
  21. wp_cache_flush( 'bb_cache_posts_post_ids' ); 
  22.  
  23. do_action( 'bb_move_topic', $topic_id, $forum_id, $topic->forum_id ); 
  24.  
  25. return $forum_id; 
  26. return false;