Skip to:
Content

BuddyPress.org

Ticket #7349: 7349.ray.patch

File 7349.ray.patch, 3.7 KB (added by r-a-y, 8 years ago)

Refreshed after recent commits.

  • src/bp-core/bp-core-buddybar.php

     
    6161         * To mimic legacy behavior, if bp_core_create_nav_link() returns false, we make
    6262         * an early exit and don't attempt to register the screen function.
    6363         */
    64         if ( false === $nav_item ) {
     64        if ( false === $nav_item && ! isset( $r['visibility'] ) ) {
    6565                return false;
    6666        }
    6767
     
    151151                'default_subnav_slug'     => $r['default_subnav_slug']
    152152        );
    153153
     154        if ( isset( $r['visibility'] ) ) {
     155                $nav_item['visibility'] = $r['visibility'];
     156        }
     157
     158        if ( isset( $r['visibility'] ) && false === $r['visibility'] ) {
     159                return $nav_item;
     160        }
     161
    154162        // Add the item to the nav.
    155163        buddypress()->{$component}->nav->add_nav( $nav_item );
    156164
     
    226234         * the logged in user is not the displayed user
    227235         * looking at their own profile, don't don't register this screen function.
    228236         */
    229         if ( empty( $r['show_for_displayed_user'] ) && ! bp_user_has_access() ) {
     237        if ( ! isset( $r['visibility'] ) && empty( $r['show_for_displayed_user'] ) && ! bp_user_has_access() ) {
    230238                return false;
    231239        }
    232240
  • src/bp-core/bp-core-catchuri.php

     
    670670                // Error message is displayed with bp_core_no_access_wp_login_error().
    671671                case 2 :
    672672                        if ( !empty( $redirect ) ) {
    673                                 bp_core_redirect( add_query_arg( array( 'action' => 'bpnoaccess' ), wp_login_url( $redirect ) ) );
     673                                bp_core_redirect( add_query_arg( array(
     674                                        'action' => 'bpnoaccess',
     675                                        'auth'   => 1
     676                                ), wp_login_url( $redirect ) ) );
    674677                        } else {
    675678                                bp_core_redirect( $root );
    676679                        }
     
    698701}
    699702
    700703/**
     704 * Login redirector.
     705 *
     706 * If a link is not publicly available, we can send members from external
     707 * locations, like following links in an email, through the login screen.
     708 *
     709 * If a user clicks on this link and is already logged in, we should attempt
     710 * to redirect the user to the authorized content instead of forcing the user
     711 * to re-authenticate.
     712 *
     713 * @since 2.9.0
     714 */
     715function bp_login_redirector() {
     716        // Redirect links must include the `redirect_to` and `auth` parameters.
     717        if ( empty( $_GET['redirect_to'] ) || empty( $_GET['auth'] ) ) {
     718                return;
     719        }
     720
     721        /*
     722         * If the user is already logged in,
     723         * skip the login form and redirect them to the content.
     724         */
     725        if ( bp_loggedin_user_id() ) {
     726                wp_safe_redirect( esc_url_raw( $_GET['redirect_to'] ) );
     727                exit;
     728        }
     729}
     730add_action( 'login_init', 'bp_login_redirector', 1 );
     731
     732/**
    701733 * Add a custom BuddyPress no access error message to wp-login.php.
    702734 *
    703735 * @since 1.5.0
  • src/bp-messages/classes/class-bp-messages-component.php

     
    162162
    163163                // Add 'Messages' to the main navigation.
    164164                $main_nav = array(
    165                         'name'                    => $nav_name,
    166                         'slug'                    => $slug,
    167                         'position'                => 50,
    168                         'show_for_displayed_user' => $access,
    169                         'screen_function'         => 'messages_screen_inbox',
    170                         'default_subnav_slug'     => 'inbox',
    171                         'item_css_id'             => $this->id
     165                        'name'                => $nav_name,
     166                        'slug'                => $slug,
     167                        'position'            => 50,
     168                        'visibility'          => $access,
     169                        'screen_function'     => 'messages_screen_inbox',
     170                        'default_subnav_slug' => 'inbox',
     171                        'item_css_id'         => $this->id
    172172                );
    173173
    174174                // Add the subnav items to the profile.