Forked from dwanjuki/mypmpro_member_directory_sql_search_where.php
Created
October 21, 2024 19:31
-
-
Save kimwhite/e215a9e1d5c24a46dba7b20fc83c1aff to your computer and use it in GitHub Desktop.
Exclude user meta from the member directory search sql query
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 // copy from here | |
/* | |
* Exclude user meta from the member directory search sql query (added a custom user field too" | |
* | |
* 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 mypmpro_member_directory_sql_search_where( $sql_search_where, $s ) { | |
$sql_search_where = " | |
AND ( | |
u.user_login LIKE '%" . esc_sql( $s ) . "%' | |
OR u.user_email LIKE '%" . esc_sql( $s ) . "%' | |
OR u.display_name LIKE '%" . esc_sql( $s ) . "%' | |
OR (um.meta_key = 'video_link_1' AND um.meta_value LIKE '%" . esc_sql( $s ) . "%') | |
) | |
"; | |
return $sql_search_where; | |
} | |
add_filter( 'pmpro_member_directory_sql_search_where', 'mypmpro_member_directory_sql_search_where', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment