bp_blogs_redirect_to_random_blog

Redirect to a random blog in the multisite network.

Description

bp_blogs_redirect_to_random_blog(); 

Usage

  1. if ( !function_exists( 'bp_blogs_redirect_to_random_blog' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-blogs/bp-blogs-actions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bp_blogs_redirect_to_random_blog(); 
  7.  

Defined (1)

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

/bp-blogs/bp-blogs-actions.php  
  1. function bp_blogs_redirect_to_random_blog() { 
  2.  
  3. // Bail if not looking for a random blog. 
  4. if ( ! bp_is_blogs_component() || ! isset( $_GET['random-blog'] ) ) 
  5. return; 
  6.  
  7. // Multisite is active so find a random blog. 
  8. if ( is_multisite() ) { 
  9. $blog = bp_blogs_get_random_blogs( 1, 1 ); 
  10. bp_core_redirect( get_home_url( $blog['blogs'][0]->blog_id ) ); 
  11.  
  12. // No multisite and still called, always redirect to root. 
  13. } else {