Skip to:
Content

BuddyPress.org

Ticket #7662: 7662.01.patch

File 7662.01.patch, 1.3 KB (added by r-a-y, 8 years ago)
  • src/bp-groups/bp-groups-actions.php

     
    9292                return;
    9393        }
    9494
    95         // Groups that the user cannot know about should return a 404 for non-members.
    96         // Unset the current group so that you're not redirected
    97         // to the default group tab.
     95        // Kill the page if group isn't visible and user does not have access.
    9896        if ( ! $is_visible ) {
    99                 buddypress()->groups->current_group = 0;
    100                 buddypress()->is_single_item        = false;
    101                 bp_do_404();
    102                 return;
     97                // If user isn't logged in, show login form.
     98                $login_form = '';
     99                if ( ! is_user_logged_in() ) {
     100                        $login_form  = sprintf( '<p>%s</p>', esc_html__( 'If you are a member of this group, login to gain access.', 'buddypress' ) );
     101                        $login_form .= wp_login_form( array(
     102                                'echo'           => false,
     103                                'label_username' => esc_html__( 'Username', 'buddypress')
     104                        ) );
     105                }
     106
     107                wp_die(
     108                        sprintf( '<p>%1$s</p>%2$s', esc_html__( 'You do not have access to this group.', 'buddypress' ), $login_form ),
     109                        __( 'Unauthorized', 'buddypress' ),
     110                        array(
     111                                'response'  => 403,
     112                                'back_link' => true
     113                        )
     114                );
     115
    103116        } else {
    104117                bp_core_no_access( $no_access_args );
    105118        }