Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
09/21/2016 10:53:11 PM (8 years ago)
Author:
r-a-y
Message:

Groups: Introduce group type functionality on the Groups Directory page.

If a group type of foo is registered with the has_directory parameter,
you can view a group directory for foo at:
example.com/groups/type/foo/

See #7210.

File:
1 edited

Legend:

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

    r11091 r11145  
    2626function groups_directory_groups_setup() {
    2727    if ( bp_is_groups_directory() ) {
     28        // Set group type if available.
     29        if ( bp_is_current_action( bp_get_groups_group_type_base() ) && bp_action_variable() ) {
     30            $matched_types = bp_groups_get_group_types( array(
     31                'has_directory'  => true,
     32                'directory_slug' => bp_action_variable(),
     33            ) );
     34
     35            // Redirect back to group directory if no match.
     36            if ( empty( $matched_types ) ) {
     37                bp_core_redirect( bp_get_groups_directory_permalink() );
     38            }
     39
     40            // Set our global variable.
     41            buddypress()->groups->current_directory_type = reset( $matched_types );
     42        }
     43
    2844        bp_update_is_directory( true, 'groups' );
    2945
Note: See TracChangeset for help on using the changeset viewer.