Re: Sort Groups Alphabetically by default (BP 1.2)
I think Dwenaus’s solution works, but he forgot a line:
function custom_group_alpha_first() {
?><option SELECTED value="alphabetical"><?php _e( 'Alphabetical', 'buddypress' ) ?></option><?php
}
add_action( 'bp_members_directory_order_options', 'custom_group_alpha_first' );
Another, less good, solution: Put the following in your theme’s functions.php:
function members_alpha_by_default( $query_string ) {
global $bp;
if ( $bp->current_component == BP_MEMBERS_SLUG && !$bp->current_action)
$query_string = 'type=alphabetical&action=alphabetical';
return $query_string;
}
add_filter( 'bp_dtheme_ajax_querystring', 'members_alpha_by_default' );
It’s not as good because it doesn’t change what the dropdown reads. A simple fix for that is just to move the Alphabetical option to the top of the list in your theme file, but if you’re going to do that you might as well just add SELECTED to the alphabetical option and skip the filtering function. Maybe I’m missing something with the bp_dtheme_ajax_querystring hook – is there a way to change what the dropdown reads? I thought that’s what ‘action’ was.