Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save davidmutero/c1a3634174b51bf2aa97d225be3f8cef to your computer and use it in GitHub Desktop.

Select an option

Save davidmutero/c1a3634174b51bf2aa97d225be3f8cef to your computer and use it in GitHub Desktop.
Limit Member Directory search to display_name only
<?php
/**
* Limit Member Directory search to display_name only.
*
* 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 my_pmpro_member_sql_search_where_display_name_only( $sql_search_where, $s ) {
$sql_search_where = "
AND (
u.display_name LIKE '%" . esc_sql( $s ) . "%'
)
";
return $sql_search_where;
}
add_filter( 'pmpro_member_directory_sql_search_where', 'my_pmpro_member_sql_search_where_display_name_only', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment