Skip to:

Opened 13 years ago

Closed 10 years ago

#3161 closed enhancement (fixed)

groups_get_groups should be able to process custom $type

Reported by: calvin_42's profile calvin_42 Owned by: imath's profile imath
Milestone: 2.1 Priority: normal
Severity: normal Version:
Component: Groups Keywords: has-patch commit


I would like to add a new sort order for the groups in the groups directory page. Thanks to the hook 'bp_groups_directory_order_options' (see groups/index.php in default theme), I have added an entry :

 * Add a sort order for the groups
function bp_custom_groups_directory_order_options() { ?>
	<option value="creative">Filter Label</option>
add_action( 'bp_groups_directory_order_options', 'bp_custom_groups_directory_order_options' );

The Ajax call made when the user changes the sort input calls successively :

  • bp_has_groups() with the $type parameter set to "creative" in my case
  • the constructor bp_groups_template()
  • groups_get_groups()

Well in this last function the switch use the "default:" operand which means BP_Groups_Group::get_active() is called.

What should be done is a new "default:" instruction which triggers a new hook "groups_get_groups_custom_type" with $type and $args for arguments.

If you're okay with it I can provide a patch.

Attachments (1)

3161.patch (1.1 KB) - added by imath 10 years ago.

Download all attachments as: .zip

Change History (7)

#1 @boonebgorges
13 years ago

I like this idea.

#2 @DJPaul
13 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Future Release

#3 @boonebgorges
10 years ago

  • Milestone changed from Future Release to 2.1
  • Severity set to normal

We now have 'order' and 'orderby' params for our group query methods (with 'type' as a shorthand for certain combos). I think it makes sense to put in the necessary filters to allow these value to be modified. This should be easy to put in place for 2.1.

10 years ago

#4 @imath
10 years ago

  • Keywords has-patch added; needs-patch removed

#5 @DJPaul
10 years ago

  • Keywords commit added

Looks good, let's get it in.

#6 @imath
10 years ago

  • Owner set to imath
  • Resolution set to fixed
  • Status changed from new to closed

In 8669:

Add two new filters to allow group order to be customized in Groups directory

The first filter bp_groups_get_orderby will help to customize the order and orderby attributes of BP_Groups_Group::get() method.
The second one bp_groups_get_orderby_converted_by_term will help to edit the corresponding SQL term/column.

Fixes #3161

Note: See TracTickets for help on using tickets.