bp_blogs_restore_data

Restore all blog associations for a given user.

Description

bp_blogs_restore_data( (int) $user_id = 0 ); 

Parameters (1)

0. $user_id — Optional. (int)
ID whose blog data should be restored.

Usage

  1. if ( !function_exists( 'bp_blogs_restore_data' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-blogs/bp-blogs-functions.php'; 
  3.  
  4. // ID whose blog data should be restored. 
  5. $user_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_blogs_restore_data($user_id); 
  9.  

Defined (1)

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

/bp-blogs/bp-blogs-functions.php  
  1. function bp_blogs_restore_data( $user_id = 0 ) { 
  2. if ( ! is_multisite() ) { 
  3. return; 
  4.  
  5. // Get the user's blogs. 
  6. $user_blogs = get_blogs_of_user( $user_id ); 
  7. if ( empty( $user_blogs ) ) { 
  8. return; 
  9.  
  10. $blogs = array_keys( $user_blogs ); 
  11.  
  12. foreach ( $blogs as $blog_id ) { 
  13. bp_blogs_add_user_to_blog( $user_id, false, $blog_id );