Skip to:
Content

BuddyPress.org

Ticket #6694: 6694.02.patch

File 6694.02.patch, 1.7 KB (added by r-a-y, 9 years ago)
  • src/bp-core/bp-core-catchuri.php

     
    210210        }
    211211
    212212        // URLs with BP_ENABLE_ROOT_PROFILES enabled won't be caught above.
    213         if ( empty( $matches ) && bp_core_enable_root_profiles() ) {
     213        if ( empty( $matches ) && bp_core_enable_root_profiles() && ! empty( $bp_uri[0] ) ) {
    214214
    215215                // Switch field based on compat.
    216216                $field = bp_is_username_compatibility_mode() ? 'login' : 'slug';
    217217
     218                /**
     219                 * Filter the portion of the URI that is the displayed user's slug.
     220                 *
     221                 * eg. example.com/ADMIN (when root profiles is enabled)
     222                 *     example.com/members/ADMIN (when root profiles isn't enabled)
     223                 *
     224                 * ADMIN would be the displayed user's slug.
     225                 *
     226                 * @since 2.6.0
     227                 *
     228                 * @param string $member_slug
     229                 */
     230                $member_slug = apply_filters( 'bp_core_set_uri_globals_member_slug', $bp_uri[0] );
     231
    218232                // Make sure there's a user corresponding to $bp_uri[0].
    219                 if ( !empty( $bp->pages->members ) && !empty( $bp_uri[0] ) && $root_profile = get_user_by( $field, $bp_uri[0] ) ) {
     233                if ( ! empty( $bp->pages->members ) && $root_profile = get_user_by( $field, $member_slug ) ) {
    220234
    221235                        // Force BP to recognize that this is a members page.
    222236                        $matches[]  = 1;
     
    272286
    273287                        // Are we viewing a specific user?
    274288                        if ( $after_member_slug ) {
     289
     290                                /** This filter is documented in bp-core/bp-core-catchuri.php */
     291                                $after_member_slug = apply_filters( 'bp_core_set_uri_globals_member_slug', $after_member_slug );
     292
    275293                                // If root profile, we've already queried for the user.
    276294                                if ( $root_profile instanceof WP_User ) {
    277295                                        $bp->displayed_user->id = $root_profile->ID;