Skip to content

Instantly share code, notes, and snippets.

@ronalfy
Last active November 12, 2021 16:21
Show Gist options
  • Save ronalfy/e7963b5405bccbe2ed3937588335fc85 to your computer and use it in GitHub Desktop.
Save ronalfy/e7963b5405bccbe2ed3937588335fc85 to your computer and use it in GitHub Desktop.
Paid Memberships Pro Directory Sort by Last Name and First Name
<?php
/**
* Sort the membership directory by lastname first, then first name.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function pmpro_custom_directory_sql_parts( $parts ) {
$parts['ORDER'] = ' ORDER BY last_name,first_name ASC ';
return $parts;
}
add_filter( 'pmpro_member_directory_sql_parts', 'pmpro_custom_directory_sql_parts', 10, 1 );
@myrafletcher
Copy link

How can I use this but use member number instead of first and last name?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment