Skip to:
Content

BuddyPress.org

Ticket #8712: 8712.patch

File 8712.patch, 2.0 KB (added by vapvarun, 7 weeks ago)
  • src/bp-members/classes/class-bp-members-component.php

    diff --git src/bp-members/classes/class-bp-members-component.php src/bp-members/classes/class-bp-members-component.php
    index 9d6b3d831..8047d2e76 100644
    class BP_Members_Component extends BP_Component { 
    10141014                                }
    10151015
    10161016                                if ( ! $single_item_action || ! $screen_function || ! is_callable( $screen_function ) ) {
     1017                                        /*
     1018                                         * Before returning 404, check if this is a valid nav item that exists
     1019                                         * but the user doesn't have access to. In that case, redirect to login
     1020                                         * instead of showing 404. This fixes the issue where non-logged-in users
     1021                                         * clicking invitation links get 404 instead of login redirect.
     1022                                         *
     1023                                         * @since 15.0.0
     1024                                         * @see https://buddypress.trac.wordpress.org/ticket/8712
     1025                                         */
     1026                                        if ( $single_item_action && ! is_user_logged_in() ) {
     1027                                                $sub_nav_item = $this->nav->get( $single_item_component . '/' . $single_item_action );
     1028
     1029                                                // If nav item exists but user doesn't have access, redirect to login.
     1030                                                if ( $sub_nav_item && isset( $sub_nav_item->user_has_access ) && false === $sub_nav_item->user_has_access ) {
     1031                                                        bp_core_no_access();
     1032                                                        return;
     1033                                                }
     1034                                        }
     1035
    10171036                                        bp_do_404();
    10181037                                        return;
    10191038                                }
    class BP_Members_Component extends BP_Component { 
    10291048                                );
    10301049
    10311050                                if ( ! $sub_nav ) {
     1051                                        /*
     1052                                         * Before returning 404, check if this is a valid nav item that exists
     1053                                         * but the user doesn't have access to. Redirect to login instead of 404.
     1054                                         *
     1055                                         * @since 15.0.0
     1056                                         * @see https://buddypress.trac.wordpress.org/ticket/8712
     1057                                         */
     1058                                        if ( $single_item_action && ! is_user_logged_in() ) {
     1059                                                $nav_item = $this->nav->get( $single_item_component . '/' . $single_item_action );
     1060
     1061                                                if ( $nav_item && isset( $nav_item->user_has_access ) && false === $nav_item->user_has_access ) {
     1062                                                        bp_core_no_access();
     1063                                                        return;
     1064                                                }
     1065                                        }
     1066
    10321067                                        bp_do_404();
    10331068                                        return;
    10341069                                }