Skip to:
Content

BuddyPress.org

Ticket #6475: 6475.01.patch

File 6475.01.patch, 2.6 KB (added by r-a-y, 10 years ago)
  • src/bp-core/bp-core-catchuri.php

     
    241241
    242242        // Rejig the offset
    243243        if ( !empty( $slug ) && ( 1 < count( $slug ) ) ) {
    244                 array_pop( $slug );
    245                 $uri_offset = count( $slug );
     244                // Only offset if not on a root profile
     245                // Fixes issues with nested members page and root profiles
     246                if ( false === $root_profile ) {
     247                        array_pop( $slug );
     248                        $uri_offset = count( $slug );
     249                }
    246250        }
    247251
    248252        // Global the unfiltered offset to use in bp_core_load_template().
     
    265269
    266270                        // Are we viewing a specific user?
    267271                        if ( $after_member_slug ) {
     272                                // If root profile, we've already queried for the user
     273                                if ( $root_profile instanceof WP_User ) {
     274                                        $bp->displayed_user->id = $root_profile->ID;
     275
    268276                                // Switch the displayed_user based on compatibility mode
    269                                 if ( bp_is_username_compatibility_mode() ) {
     277                                } elseif ( bp_is_username_compatibility_mode() ) {
    270278                                        $bp->displayed_user->id = (int) bp_core_get_userid( urldecode( $after_member_slug ) );
     279
    271280                                } else {
    272281                                        $bp->displayed_user->id = (int) bp_core_get_userid_from_nicename( $after_member_slug );
    273282                                }
    274283                        }
    275284
     285                        // Bump the offset.
     286                        if ( bp_displayed_user_id() ) {
     287                                if ( isset( $bp_uri[$uri_offset + 2] ) ) {
     288                                        $bp_uri                = array_merge( array(), array_slice( $bp_uri, $uri_offset + 2 ) );
     289                                        $bp->current_component = $bp_uri[0];
     290
     291                                // No component, so default will be picked later
     292                                } else {
     293                                        $bp_uri                = array_merge( array(), array_slice( $bp_uri, $uri_offset + 2 ) );
     294                                        $bp->current_component = '';
     295                                }
     296
     297                                // Reset the offset
     298                                $uri_offset = 0;
     299                        }
     300
     301
    276302                        // Is this a member type directory?
    277303                        if ( ! bp_displayed_user_id() && $after_member_slug === apply_filters( 'bp_members_member_type_base', _x( 'type', 'member type URL base', 'buddypress' ) ) && ! empty( $bp_uri[ $uri_offset + 2 ] ) ) {
    278304                                $matched_types = bp_get_member_types( array(
     
    304330                                }
    305331                        }
    306332
    307                         // Bump the offset.
    308                         if ( bp_displayed_user_id() ) {
    309                                 if ( isset( $bp_uri[$uri_offset + 2] ) ) {
    310                                         $bp_uri                = array_merge( array(), array_slice( $bp_uri, $uri_offset + 2 ) );
    311                                         $bp->current_component = $bp_uri[0];
    312 
    313                                 // No component, so default will be picked later
    314                                 } else {
    315                                         $bp_uri                = array_merge( array(), array_slice( $bp_uri, $uri_offset + 2 ) );
    316                                         $bp->current_component = '';
    317                                 }
    318                         }
    319 
    320                         // Reset the offset
    321                         $uri_offset = 0;
    322333                }
    323334        }
    324335