Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/31/2017 08:31:10 PM (8 years ago)
Author:
r-a-y
Message:

Groups: Fix AJAX pagination when on a group type directory page.

This commit moves group type directory detection from the
'template_redirect' hook to our groups component class to ensure
detection is available for AJAX purposes.

Commit also changes invalid group type directory requests to 404 instead
of redirecting back to the main Groups directory.

Props r-a-y, dcavins.

Fixes #7423.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/classes/class-bp-groups-component.php

    r11360 r11405  
    266266        } else {
    267267            $this->current_group = 0;
     268        }
     269
     270        // Set group type if available.
     271        if ( bp_is_groups_directory() && bp_is_current_action( bp_get_groups_group_type_base() ) && bp_action_variable() ) {
     272            $matched_types = bp_groups_get_group_types( array(
     273                'has_directory'  => true,
     274                'directory_slug' => bp_action_variable(),
     275            ) );
     276
     277            // Set 404 if we do not have a valid group type.
     278            if ( empty( $matched_types ) ) {
     279                bp_do_404();
     280                return;
     281            }
     282
     283            // Set our directory type marker.
     284            $this->current_directory_type = reset( $matched_types );
    268285        }
    269286
     
    298315
    299316        // If the user was attempting to access a group, but no group by that name was found, 404.
    300         if ( bp_is_groups_component() && empty( $this->current_group ) && bp_current_action() && !in_array( bp_current_action(), $this->forbidden_names ) ) {
     317        if ( bp_is_groups_component() && empty( $this->current_group ) && empty( $this->current_directory_type ) && bp_current_action() && ! in_array( bp_current_action(), $this->forbidden_names ) ) {
    301318            bp_do_404();
    302319            return;
Note: See TracChangeset for help on using the changeset viewer.