Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/06/2017 03:46:07 PM (9 years ago)
Author:
djpaul
Message:

Groups: use class methods to check if user has visibility of a group.

Improves upon existing duplication of logic.

Fixes #7608

Props dcavins

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/bp-groups-actions.php

    r11393 r11761  
    4242        $current_group   = groups_get_current_group();
    4343        $user_has_access = $current_group->user_has_access;
     44        $is_visible      = $current_group->is_visible;
    4445        $no_access_args  = array();
    4546
    46         if ( ! $user_has_access && 'hidden' !== $current_group->status ) {
     47        // The user can know about the group but doesn't have full access.
     48        if ( ! $user_has_access && $is_visible ) {
    4749                // Always allow access to home and request-membership.
    4850                if ( bp_is_current_action( 'home' ) || bp_is_current_action( 'request-membership' ) ) {
    … …  
    9193        }
    9294
    93         // Hidden groups should return a 404 for non-members.
     95        // Groups that the user cannot know about should return a 404 for non-members.
    9496        // Unset the current group so that you're not redirected
    9597        // to the default group tab.
    96         if ( 'hidden' == $current_group->status ) {
     98        if ( ! $is_visible ) {
    9799                buddypress()->groups->current_group = 0;
    98100                buddypress()->is_single_item        = false;
    … …  
    489491                }
    490492
    491                 $redirect = bp_get_group_permalink( groups_get_current_group() );
    492 
    493                 if( 'hidden' == $bp->groups->current_group->status ) {
     493                $group = groups_get_current_group();
     494                $redirect = bp_get_group_permalink( $group );
     495
     496                if ( ! $group->is_visible ) {
    494497                        $redirect = trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() );
    495498                }
Note: See TracChangeset for help on using the changeset viewer.