Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
GravityView - Sort by Last Name when sorting by the Full Name
<?php
/**
* Override how to sort when sorting by full name.
*
* Available in GravityView 1.7.4 and higher.
*
* @param string $name_part `first` or `last` (default: `first`)
* @param string $sort_field_id Field used for sorting
* @param int $form_id GF Form ID
*
* @return string Full name sorting option (`first` or `last`)
*/
function gravityview_use_last_name_sorting( $name_part, $sort_field_id, $form_id ) {
// If you want to sort by different fields depending on the field ID, you can use
// the $sort_field_id and $form_id parameters to run some logic here, too.
return 'last';
}
add_filter('gravityview/sorting/full-name', 'gravityview_use_last_name_sorting', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.