WC_Report_Customer_List::order_by_last_name()
Order users by name.
Метод класса: WC_Report_Customer_List{}
Хуков нет.
Возвращает
WP_User_Query
.
Использование
$WC_Report_Customer_List = new WC_Report_Customer_List(); $WC_Report_Customer_List->order_by_last_name( $query );
- $query(WP_User_Query) (обязательный)
- Query that gets passed through.
Код WC_Report_Customer_List::order_by_last_name() WC Report Customer List::order by last name WC 9.4.2
public function order_by_last_name( $query ) { global $wpdb; $s = ! empty( $_REQUEST['s'] ) ? wp_unslash( $_REQUEST['s'] ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized $query->query_from .= " LEFT JOIN {$wpdb->usermeta} as meta2 ON ({$wpdb->users}.ID = meta2.user_id) "; $query->query_where .= " AND meta2.meta_key = 'last_name' "; $query->query_orderby = ' ORDER BY meta2.meta_value, user_login ASC '; if ( $s ) { $query->query_from .= " LEFT JOIN {$wpdb->usermeta} as meta3 ON ({$wpdb->users}.ID = meta3.user_id)"; $query->query_where .= " AND ( user_login LIKE '%" . esc_sql( str_replace( '*', '', $s ) ) . "%' OR user_nicename LIKE '%" . esc_sql( str_replace( '*', '', $s ) ) . "%' OR meta3.meta_value LIKE '%" . esc_sql( str_replace( '*', '', $s ) ) . "%' ) "; $query->query_orderby = ' GROUP BY ID ' . $query->query_orderby; } return $query; }