Skip to content

Instantly share code, notes, and snippets.

@zackkatz
Created March 26, 2015 01:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zackkatz/cd42bee4f361f422824e to your computer and use it in GitHub Desktop.
Save zackkatz/cd42bee4f361f422824e to your computer and use it in GitHub Desktop.
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