bbp_filter_user_id( int $user_id, bool $displayed_user_fallback = true, bool $current_user_fallback = false )
Filter the current Forums user ID with the current BuddyBoss user ID
Description
Parameters
- $user_id
-
(Required)
- $displayed_user_fallback
-
(Optional)
Default value: true
- $current_user_fallback
-
(Optional)
Default value: false
Return
(int) User ID
Source
File: bp-forums/functions.php
function bbp_filter_user_id( $user_id = 0, $displayed_user_fallback = true, $current_user_fallback = false ) {
// Define local variable
$bbp_user_id = 0;
// Get possible user ID's
$did = bp_displayed_user_id();
$lid = bp_loggedin_user_id();
// Easy empty checking
if ( !empty( $user_id ) && is_numeric( $user_id ) )
$bbp_user_id = $user_id;
// Currently viewing or editing a user
elseif ( ( true === $displayed_user_fallback ) && !empty( $did ) )
$bbp_user_id = $did;
// Maybe fallback on the current_user ID
elseif ( ( true === $current_user_fallback ) && !empty( $lid ) )
$bbp_user_id = $lid;
return $bbp_user_id;
}
Changelog
| Version | Description |
|---|---|
| bbPress (r3552) | 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.