bb_set_auth_cookie

The BuddyPress bb set auth cookie function.

Description

bb_set_auth_cookie( $user_id, (constant) $remember = false, (bool) $schemes = false ); 

Parameters (3)

0. $user_id
The user id.
1. $remember — Optional. (constant) => false
The remember.
2. $schemes — Optional. (bool) => false
The schemes.

Usage

  1. if ( !function_exists( 'bb_set_auth_cookie' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/functions.bb-pluggable.php'; 
  3.  
  4. // The user id. 
  5. $user_id = null; 
  6.  
  7. // The remember. 
  8. $remember = false; 
  9.  
  10. // The schemes. 
  11. $schemes = false; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = bb_set_auth_cookie($user_id, $remember, $schemes); 
  15.  

Defined (1)

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

/bp-forums/bbpress/bb-includes/functions.bb-pluggable.php  
  1. function bb_set_auth_cookie( $user_id, $remember = false, $schemes = false ) { 
  2. global $wp_auth_object; 
  3.  
  4. if ( $remember ) { 
  5. $expiration = $expire = time() + 1209600; 
  6. } else { 
  7. $expiration = time() + 172800; 
  8. $expire = 0; 
  9.  
  10. if ( true === $schemes ) { 
  11. $schemes = array( 'secure_auth', 'logged_in' ); 
  12. } elseif ( !is_array( $schemes ) ) { 
  13. $schemes = array(); 
  14. if ( force_ssl_login() || force_ssl_admin() ) { 
  15. $schemes[] = 'secure_auth'; 
  16. if ( !( force_ssl_login() && force_ssl_admin() ) ) { 
  17. $schemes[] = 'auth'; 
  18. $schemes[] = 'logged_in'; 
  19. $schemes = array_unique( $schemes ); 
  20.  
  21. foreach ( $schemes as $scheme ) { 
  22. $wp_auth_object->set_auth_cookie( $user_id, $expiration, $expire, $scheme );