Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
08/08/2012 05:13:00 PM (14 years ago)
Author:
boonebgorges
Message:

Moves bp_displayed_user_id() and bp_loggedin_user_id() to Core component

The function bp_displayed_user_id() and bp_loggedin_user_id() are referenced
throughout BuddyPress's Core component when doing things like checking page
type. In certain circumstances, these checks might happen after the Core
component is loaded, but before the Members component is loaded. For this
reason, it's important that the functions live in Core rather than Members,
to avoid fatal errors.

Fixes #4403

Props steve7777

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-template.php

    r6198 r6249  
    752752    }
    753753
     754/**
     755 * Get the id of the currently displayed user
     756 *
     757 * @uses apply_filters() Filter 'bp_displayed_user_id' to change this value
     758 * @return int
     759 */
     760function bp_displayed_user_id() {
     761
     762    static $id = 0;
     763
     764    if ( empty( $id ) ) {
     765        global $bp;
     766        $id = !empty( $bp->displayed_user->id ) ? $bp->displayed_user->id : 0;
     767    }
     768
     769    return apply_filters( 'bp_displayed_user_id', $id );
     770}
     771
     772/**
     773 * Get the id of the currently logged-in user
     774 *
     775 * @uses apply_filters() Filter 'bp_loggedin_user_id' to change this value
     776 * @return int
     777 */
     778function bp_loggedin_user_id() {
     779
     780    static $id = 0;
     781
     782    if ( empty( $id ) ) {
     783        global $bp;
     784        $id = !empty( $bp->loggedin_user->id ) ? $bp->loggedin_user->id : 0;
     785    }
     786
     787    return apply_filters( 'bp_loggedin_user_id', $id );
     788}
     789
    754790/** is_() functions to determine the current page *****************************/
    755791
Note: See TracChangeset for help on using the changeset viewer.