bb_auth

The BuddyPress bb auth function.

Description

bb_auth( (string) $scheme = 'auth' ); 

Parameters (1)

0. $scheme — Optional. (string) => 'auth'
The scheme.

Usage

  1. if ( !function_exists( 'bb_auth' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/functions.bb-pluggable.php'; 
  3.  
  4. // The scheme. 
  5. $scheme = 'auth'; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bb_auth($scheme); 
  9.  

Defined (1)

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

/bp-forums/bbpress/bb-includes/functions.bb-pluggable.php  
  1. function bb_auth( $scheme = 'auth' ) { // Checks if a user has a valid cookie, if not redirects them to the main page 
  2. if ( !bb_validate_auth_cookie( '', $scheme ) ) { 
  3. if ( 'auth' === $scheme && !bb_is_user_logged_in() ) { 
  4. $protocol = 'http://'; 
  5. if ( is_ssl() ) { 
  6. $protocol = 'https://'; 
  7. wp_redirect( bb_get_uri( 'bb-login.php', array( 'redirect_to' => $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ), BB_URI_CONTEXT_HEADER + BB_URI_CONTEXT_BB_USER_FORMS ) ); 
  8. } else { 
  9. exit;