bp_loggedin_user_id()

Get the ID of the currently logged-in user.

Description

Return

(int) ID of the logged-in user.

Source

File: bp-core/bp-core-template.php

1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
function bp_loggedin_user_id() {
    $bp = buddypress();
    $id = !empty( $bp->loggedin_user->id )
        ? $bp->loggedin_user->id
        : 0;
 
    /**
     * Filters the ID of the currently logged-in user.
     *
     * @since BuddyPress 1.0.0
     *
     * @param int $id ID of the currently logged-in user.
     */
    return (int) apply_filters( 'bp_loggedin_user_id', $id );
}

Changelog

Changelog
Version Description
BuddyPress 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.