Skip to:
Content

BuddyPress.org

Changeset 7978


Ignore:
Timestamp:
02/25/2014 12:10:56 AM (12 years ago)
Author:
djpaul
Message:

Groups: When preparing the Group Members template loop, use the details of the group passed to the class rather than always using $bp->groups->current_group.

The global property is usually set to the currently-displayed group according to BP's URI parsing, but if the Group Members template loop is used outside a typical Groups context (such as in 3rd party plugin, or a unit test), then this variable isn't set. At worse, it'd use the wrong group's details to build the template loop.

Fixes #5420

File:
1 edited

Legend:

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

    r7965 r7978  
    20292029        $this->pag_num  = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
    20302030
     2031        /**
     2032         * Check the current group is the same as the supplied group ID.
     2033         * It can differ when using {@link bp_group_has_members()} outside the Groups screens.
     2034         */
     2035        $current_group = groups_get_current_group();
     2036        if ( ! $current_group || $current_group && $current_group->id !== bp_get_current_group_id() ) {
     2037            $current_group = groups_get_group( array( 'group_id' => $r['group_id'] ) );
     2038        }
     2039
    20312040        // Assemble the base URL for pagination
    2032         $base_url = trailingslashit( bp_get_group_permalink( groups_get_current_group() ) . bp_current_action() );
     2041        $base_url = trailingslashit( bp_get_group_permalink( $current_group ) . bp_current_action() );
    20332042        if ( bp_action_variable() ) {
    20342043            $base_url = trailingslashit( $base_url . bp_action_variable() );
Note: See TracChangeset for help on using the changeset viewer.