bb_fermion

The BuddyPress bb fermion function.

Description

bb_fermion( $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_fermion' ) ) { 
  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_fermion($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_fermion( $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_delete_usermeta( $user_id, 'is_bozo' ); 
  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 ( --$topic->bozos[$user_id] < 1 ) 
  16. unset($topic->bozos[$user_id]); 
  17. bb_update_topicmeta( $topic_id, 'bozos', $topic->bozos ); 
  18.  
  19. if ( --$user->{$bozo_topics_key}[$topic_id] < 1 ) 
  20. unset($user->{$bozo_topics_key}[$topic_id]); 
  21. bb_update_usermeta( $user_id, $bozo_topics_key, $user->$bozo_topics_key );