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

48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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

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.