Skip to:
Content

BuddyPress.org

Changeset 13618


Ignore:
Timestamp:
10/22/2023 05:47:26 AM (3 years ago)
Author:
imath
Message:

Make sure to initialize BP_Core_Nav with a user ID

  • By default use the logged in ID.
  • Use the displayed user ID if available.
  • Update 12.0.0 credits.

Props emaralive, awol

Closes https://github.com/buddypress/buddypress/pull/177
Fixes #9009
See #9002

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/classes/class-bp-admin.php

    r13614 r13618  
    11291129                        </h3>
    11301130                        <p class="wp-credits-list">
     1131                                <a href="https://profiles.wordpress.org/awol/">awol</a>,
    11311132                                <a href="https://profiles.wordpress.org/bouncingsprout/">Ben Roberts (bouncingsprout)</a>,
    11321133                                <a href="https://profiles.wordpress.org/boonebgorges/">Boone B Gorges (boonebgorges)</a>,
  • trunk/src/bp-members/classes/class-bp-members-component.php

    r13583 r13618  
    231231                $this->activate_permastruct = bp_get_activate_slug() . '/%' . $this->rewrite_ids['member_activate'] . '%';
    232232
     233                // Init the User's ID to use to build the Nav for.
     234                $user_id = bp_loggedin_user_id();
     235
    233236                /** Logged in user ***************************************************
    234237                 */
    235238
    236239                // The core userdata of the user who is currently logged in.
    237                 $bp->loggedin_user->userdata = bp_core_get_core_userdata( bp_loggedin_user_id() );
     240                $bp->loggedin_user->userdata = bp_core_get_core_userdata( $user_id );
    238241
    239242                // Fetch the full name for the logged in user.
     
    241244
    242245                // Hits the DB on single WP installs so get this separately.
    243                 $bp->loggedin_user->is_super_admin = $bp->loggedin_user->is_site_admin = is_super_admin( bp_loggedin_user_id() );
     246                $bp->loggedin_user->is_super_admin = $bp->loggedin_user->is_site_admin = is_super_admin( $user_id );
    244247
    245248                // The domain for the user currently logged in. eg: http://example.com/members/andy.
    246                 $bp->loggedin_user->domain = bp_members_get_user_url( bp_loggedin_user_id() );
     249                $bp->loggedin_user->domain = bp_members_get_user_url( $user_id );
    247250
    248251                /**
     
    252255                 */
    253256                if ( bp_displayed_user_id() ) {
     257                        // We're viewing a speciific user, switch the ID to use for the Nav to this one.
     258                        $user_id = bp_displayed_user_id();
     259
    254260                        // The core userdata of the user who is currently being displayed.
    255                         $bp->displayed_user->userdata = bp_core_get_core_userdata( bp_displayed_user_id() );
     261                        $bp->displayed_user->userdata = bp_core_get_core_userdata( $user_id );
    256262
    257263                        // Fetch the full name displayed user.
     
    259265
    260266                        // The domain for the user currently being displayed.
    261                         $bp->displayed_user->domain = bp_members_get_user_url( bp_displayed_user_id() );
     267                        $bp->displayed_user->domain = bp_members_get_user_url( $user_id );
    262268
    263269                        // If A user is displayed, check if there is a front template
     
    270276                 */
    271277
    272                 $this->nav = new BP_Core_Nav();
     278                $this->nav = new BP_Core_Nav( $user_id );
    273279
    274280                /** Signup ***********************************************************
Note: See TracChangeset for help on using the changeset viewer.