Created
April 4, 2025 06:10
-
-
Save JarrydLong/4af46d2a8639bf00f54b96dc6d97d0f8 to your computer and use it in GitHub Desktop.
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 //do not copy | |
/** | |
* This recipe filters the search request from the member directory into the membership map | |
* | |
* 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 mypmpromm_filter_searches( $sql_parts, $levels, $s, $pn, $limit, $start, $end ) { | |
if( ! empty( $_REQUEST['ps'] ) ) { | |
$s = sanitize_text_field( $_REQUEST['ps'] ); | |
$sql_parts['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_value LIKE '%" . esc_sql($s) . "%') "; | |
} | |
return $sql_parts; | |
} | |
add_filter( 'pmpro_membership_maps_sql_parts', 'mypmpromm_filter_searches', 10, 7 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment