WordPress at a glance
function is not described

WP_User_Query::get_search_sql() protected WP 3.1.0

Used internally to generate an SQL string for searching across multiple columns

{} It's a method of the class: WP_User_Query{}

No Hooks.

Return

String. Nothing.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_search_sql( $string, $cols, $wild );
$string(string) (required)
-
$cols(array) (required)
-
$wild(true|false)
Whether to allow wildcard searches. Single site allows leading and trailing wildcards, Network Admin only trailing.
Default: false for Network Admin, true for single site

Notes

  • Global. wpdb. $wpdb WordPress database abstraction object.

Changelog

Since 3.1.0 Introduced.

Code of WP_User_Query::get_search_sql() WP 5.7.2

<?php
protected function get_search_sql( $string, $cols, $wild = false ) {
	global $wpdb;

	$searches      = array();
	$leading_wild  = ( 'leading' === $wild || 'both' === $wild ) ? '%' : '';
	$trailing_wild = ( 'trailing' === $wild || 'both' === $wild ) ? '%' : '';
	$like          = $leading_wild . $wpdb->esc_like( $string ) . $trailing_wild;

	foreach ( $cols as $col ) {
		if ( 'ID' === $col ) {
			$searches[] = $wpdb->prepare( "$col = %s", $string );
		} else {
			$searches[] = $wpdb->prepare( "$col LIKE %s", $like );
		}
	}

	return ' AND (' . implode( ' OR ', $searches ) . ')';
}