Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/20/2016 07:16:16 PM (8 years ago)
Author:
boonebgorges
Message:

URL routing: Filter the portion of the URI immediately after the 'members' slug.

This allows customizations for routing that is based on something other than
user_nicename.

Props kmb@…, r-a-y.
Fixes #6694.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-catchuri.php

    r10497 r10714  
    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.
     
    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 ) {
Note: See TracChangeset for help on using the changeset viewer.