Created
March 26, 2015 01:05
-
-
Save zackkatz/cd42bee4f361f422824e to your computer and use it in GitHub Desktop.
GravityView - Sort by Last Name when sorting by the Full Name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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