bp_groupblog_remove_user

Bp_groupblog_remove_user( $group_id, $user_id = false ).

Description

bp_groupblog_remove_user( $group_id, (bool) $user_id = false ); 

Called when user leaves.

Parameters (2)

0. $group_id
The group id.
1. $user_id — Optional. (bool) => false
The user id.

Usage

  1. if ( !function_exists( 'bp_groupblog_remove_user' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bp-groupblog/bp-groupblog.php'; 
  3.  
  4. // The group id. 
  5. $group_id = null; 
  6.  
  7. // The user id. 
  8. $user_id = false; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bp_groupblog_remove_user($group_id, $user_id); 
  12.  

Defined (1)

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

/bp-groupblog.php  
  1. function bp_groupblog_remove_user( $group_id, $user_id = false ) { 
  2. $blog_id = get_groupblog_blog_id( $group_id ); 
  3.  
  4. if ( ! $user_id ) 
  5. $user_id = bp_loggedin_user_id(); 
  6.  
  7. $user = new WP_User( $user_id ); 
  8. $user->for_blog( $blog_id ); 
  9. $user->set_role( 'subscriber' ); 
  10. wp_cache_delete( $user_id, 'users' );