BP_Groups_Group::convert_orderby_to_order_by_term( string $orderby )
Convert the ‘orderby’ param into a proper SQL term/column.
Description
Parameters
- $orderby
-
(Required) Orderby term as passed to get().
Return
(string) $order_by_term SQL-friendly orderby term.
Source
File: bp-groups/classes/class-bp-groups-group.php
protected static function convert_orderby_to_order_by_term( $orderby ) {
$order_by_term = '';
switch ( $orderby ) {
case 'date_created' :
default :
$order_by_term = 'g.date_created';
break;
case 'last_activity' :
$order_by_term = 'gm_last_activity.meta_value';
break;
case 'total_member_count' :
$order_by_term = 'CONVERT(gm_total_member_count.meta_value, SIGNED)';
break;
case 'name' :
$order_by_term = 'g.name';
break;
case 'random' :
$order_by_term = 'rand()';
break;
case 'meta_id' :
$order_by_term = buddypress()->groups->table_name_groupmeta . '.id';
break;
}
return $order_by_term;
}
Changelog
| Version | Description |
|---|---|
| BuddyPress 1.8.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.