Skip to:
Content
Pages
Categories
Search
Top
Bottom

Problem with $bp->displayed_user->id


  • dlt101
    Participant

    @dlt101

    The following line of code (run during ‘init’ action) …
    $userID = $bp->displayed_user->id;
    produces an error in the debug.log.
    Undefined property: stdClass::$id

    Yet if I print_r($bp->displayed_user), the ‘id’ property is there and set.

    I am using the latest WordPress and Buddypress.
    What am I missing?

Viewing 2 replies - 1 through 2 (of 2 total)

  • shanebp
    Moderator

    @shanebp

    Use this instead, and you won’t need the global $bp:
    bp_displayed_user_id();

    run during ‘init’ action

    That hook may run too early.
    Run it on a function hooked to bp_ready.


    dlt101
    Participant

    @dlt101

    ‘bp_ready’ did the trick!
    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Problem with $bp->displayed_user->id’ is closed to new replies.
Skip to toolbar