bp_member_switching_set_olduser_cookie( int $old_user_id, bool $pop = false, string $token = '' )
Sets authorization cookies containing the originating user information.
Description
Parameters
- $old_user_id
-
(Required) The ID of the originating user, usually the current logged in user.
- $pop
-
(Optional) Pop the latest user off the auth cookie, instead of appending the new one.
Default value: false
- $token
-
(Optional) The old user's session token to store for later reuse.
Default value: ''
Source
File: bp-members/bp-members-functions.php
function bp_member_switching_set_olduser_cookie( $old_user_id, $pop = false, $token = '' ) { $secure_auth_cookie = BP_Core_Members_Switching::secure_auth_cookie(); $secure_olduser_cookie = BP_Core_Members_Switching::secure_olduser_cookie(); $expiration = time() + 172800; // 48 hours $auth_cookie = bp_member_switching_get_auth_cookie(); $olduser_cookie = wp_generate_auth_cookie( $old_user_id, $expiration, 'logged_in', $token ); if ( $secure_auth_cookie ) { $auth_cookie_name = BP_MEMBER_SWITCHING_SECURE_COOKIE; $scheme = 'secure_auth'; } else { $auth_cookie_name = BP_MEMBER_SWITCHING_COOKIE; $scheme = 'auth'; } if ( $pop ) { array_pop( $auth_cookie ); } else { array_push( $auth_cookie, wp_generate_auth_cookie( $old_user_id, $expiration, $scheme, $token ) ); } $auth_cookie = json_encode( $auth_cookie ); /** This filter is documented in wp-includes/pluggable.php */ if ( ! apply_filters( 'send_auth_cookies', true ) ) { return; } setcookie( $auth_cookie_name, $auth_cookie, $expiration, SITECOOKIEPATH, COOKIE_DOMAIN, $secure_auth_cookie, true ); setcookie( BP_MEMBER_SWITCHING_OLDUSER_COOKIE, $olduser_cookie, $expiration, COOKIEPATH, COOKIE_DOMAIN, $secure_olduser_cookie, true ); }
Changelog
Version | Description |
---|---|
BuddyBoss 1.0.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.