bb_bozon

The BuddyPress bb bozon function.

Description

bb_bozon( $user_id, (int) $topic_id = 0 ); 

Parameters (2)

0. $user_id
The user id.
1. $topic_id — Optional. (int)
The topic id.

Usage

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

Defined (1)

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

/bp-forums/bbpress/bb-plugins/bozo.php  
  1. function bb_bozon( $user_id, $topic_id = 0 ) { 
  2. global $bbdb; 
  3.  
  4. $user_id = (int) $user_id; 
  5. $topic_id = (int) $topic_id; 
  6.  
  7. if ( !$topic_id ) 
  8. bb_update_usermeta( $user_id, 'is_bozo', 1 ); 
  9. else { 
  10. $topic = get_topic( $topic_id ); 
  11. $user = bb_get_user( $user_id ); 
  12.  
  13. $bozo_topics_key = $bbdb->prefix . 'bozo_topics'; 
  14.  
  15. if ( isset($topic->bozos[$user_id]) ) 
  16. $topic->bozos[$user_id]++; 
  17. elseif ( isset( $topic->bozos ) && is_array( $topic->bozos ) ) 
  18. $topic->bozos[$user_id] = 1; 
  19. else 
  20. $topic->bozos = array($user_id => 1); 
  21. bb_update_topicmeta( $topic_id, 'bozos', $topic->bozos ); 
  22.  
  23. if ( isset($user->{$bozo_topics_key}[$topic_id]) ) 
  24. $user->{$bozo_topics_key}[$topic_id]++; 
  25. elseif ( isset( $user->bozo_topics ) && is_array($user->bozo_topics) ) 
  26. $user->{$bozo_topics_key}[$topic_id] = 1; 
  27. else 
  28. $user->$bozo_topics_key = array($topic_id => 1); 
  29. bb_update_usermeta( $user_id, $bozo_topics_key, $user->$bozo_topics_key );