Pesquisar por E-mail do User e outros campos com JetSmartFilters no WordPress
/* Adicione esse trecho no functions.php do tema [ou tema filho mais seguro] */
/* no campo search do smartfilters no query variable coloque:
user_prop::user_email; user_prop::user_login; user_prop::user_nicename; user_prop::ID; user_prop::user_url
--->> importante use ponto e virgula (;) para adicionar mais de um termo caso necessário. */
/*
Veja o Prints:
https://imgur.com/a/amQwmzv
https://imgur.com/a/3foNmbH
*/
add_filter( 'jet-smart-filters/query/final-query', function( $query ) {
foreach ( $query['meta_query'] as $index => $meta_query_item ) {
if ( false !== strpos( $query['meta_query'][$index]['key'], 'user_prop::' ) ) {
$prop = explode( '::', $query['meta_query'][$index]['key'] )[1];
$query['meta_query'][$index]['key'] = $prop;
$query['search_columns'] = array( $prop );
$query['search'] = '*'.$query['meta_query'][$index]['value'].'*';
foreach( $query['meta_query'] as $i => $meta_query_item ) {
if ( $meta_query_item['key'] == $prop ) {
unset( $query['meta_query'][$i] );
}
}
}
}
return $query;
} );
```
Desenvolvido por: Dante Testa