pre_user_query
最后更新于:2021-11-27 21:02:10
do_action_ref_array( ‘pre_user_query’, GC_User_Query $query )
Fires after the GC_User_Query has been parsed, and before the query is executed.
参数
- $query
-
(GC_User_Query)
Current instance of GC_User_Query (passed by reference).
源文件
文件: gc-includes/class-gc-user-query.php
<?php add_action( 'pre_user_query', function( $uqi ) { global $gcdb; $search = ''; if ( isset( $uqi->query_vars['search'] ) ) $search = trim( $uqi->query_vars['search'] ); if ( $search ) { $search = trim($search, '*'); $the_search = '%'.$search.'%'; $search_meta = $gcdb->prepare(" ID IN ( SELECT user_id FROM {$gcdb->usermeta} WHERE ( ( meta_key='first_name' OR meta_key='last_name' ) AND {$gcdb->usermeta}.meta_value LIKE '%s' ) )", $the_search); $uqi->query_where = str_replace( 'WHERE 1=1 AND (', "WHERE 1=1 AND (" . $search_meta . " OR ", $uqi->query_where ); } });