Skip to:
Content

BuddyPress.org

Changeset 5385


Ignore:
Timestamp:
11/27/2011 04:08:51 AM (13 years ago)
Author:
boonebgorges
Message:

Provides a valid fallback redirect for situations where the default component is set to something that is unavailable for the logged-in user (such as messages, when viewing someone else's profile). Fixes #3707

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-buddybar.php

    r5373 r5385  
    260260            // depending on whether the current user is logged in
    261261            if ( is_user_logged_in() ) {
     262                if ( !bp_is_my_profile() && !$bp->bp_nav[$bp->default_component]['show_for_displayed_user'] ) {
     263                    // This covers the edge case where the default component is
     264                    // a non-public tab, like 'messages'
     265                    if ( bp_is_active( 'activity' ) && isset( $bp->pages->activity ) ) {
     266                        $redirect_to = bp_displayed_user_domain() . bp_get_activity_slug();
     267                    } else {
     268                        $redirect_to = bp_displayed_user_domain() . ( 'xprofile' == $bp->profile->id ? 'profile' : $bp->profile->id );
     269                    }
     270                   
     271                    $message     = '';
     272                } else {
     273                    $message     = __( 'You do not have access to this page.', 'buddypress' );
     274                    $redirect_to = bp_displayed_user_domain();
     275                }
     276               
    262277                // Off-limits to this user. Throw an error and redirect to the displayed user's domain
    263278                bp_core_no_access( array(
    264                     'message'  => __( 'You do not have access to this page.', 'buddypress' ),
    265                     'root'     => bp_displayed_user_domain(),
     279                    'message'  => $message,
     280                    'root'     => $redirect_to,
    266281                    'redirect' => false
    267282                ) );
Note: See TracChangeset for help on using the changeset viewer.