Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/26/2011 03:44:02 AM (14 years ago)
Author:
boonebgorges
Message:

404 when attempting to access the URL of a hidden group. Fixes #3462

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups/bp-groups-loader.php

    r5329 r5373  
    167167        if ( bp_is_groups_component() && !empty( $this->current_group ) ) {
    168168
    169             if ( !empty( $bp->current_action ) && !$this->current_group->user_has_access ) {
    170                 if ( is_user_logged_in() ) {
    171                     // Off-limits to this user. Throw an error and redirect to the group's home page
    172                     bp_core_no_access( array(
    173                         'message'  => __( 'You do not have access to this group.', 'buddypress' ),
    174                         'root'     => bp_get_group_permalink( $bp->groups->current_group ),
    175                         'redirect' => false
    176                     ) );
     169            if ( !$this->current_group->user_has_access ) {
     170                if ( 'hidden' == $this->current_group->status ) {
     171                    // Hidden groups should return a 404 for non-members.
     172                    // Unset the current group so that you're not redirected
     173                    // to the default group tab
     174                    $this->current_group = 0;
     175                    $bp->is_single_item  = false;
     176                    bp_do_404();
     177                    return;
    177178                } else {
    178                     // Allow the user to log in
    179                     bp_core_no_access();
     179                    if ( is_user_logged_in() ) {
     180                        // Off-limits to this user. Throw an error and redirect to the group's home page
     181                        bp_core_no_access( array(
     182                            'message'  => __( 'You do not have access to this group.', 'buddypress' ),
     183                            'root'     => bp_get_group_permalink( $bp->groups->current_group ),
     184                            'redirect' => false
     185                        ) );
     186                    } else {
     187                        // Allow the user to log in
     188                        bp_core_no_access();
     189                    }
    180190                }
    181191
    182192            // User has access. Default to a particular group extension if not specified on the URL
    183             } elseif ( empty( $bp->current_action ) && $this->current_group->user_has_access ) {
     193            } elseif ( !bp_current_action() ) {
    184194                $bp->current_action = apply_filters( 'bp_groups_default_extension', defined( 'BP_GROUPS_DEFAULT_EXTENSION' ) ? BP_GROUPS_DEFAULT_EXTENSION :  'home' );
    185195            }
Note: See TracChangeset for help on using the changeset viewer.