SearchWP

Available since: 2.5

searchwp_log_search

View Parameters »

By default SearchWP logs searches to allow for more insight into user behavior.

Example: If you would like to conditionally prevent searches from being logged, add something like this to your theme’s functions.php:

<?php
function my_searchwp_log_search( $log, $engine, $search_terms, $number_of_results ) {
// TODO: check to see whether you want to log
return true; // false to prevent logging
}
add_filter( 'searchwp_log_search', 'my_searchwp_log_search', 10, 4 );
view raw gistfile1.php hosted with ❤ by GitHub

Example: If you would like to prevent SearchWP from logging searches from logged in users, add this to your theme’s functions.php:

<?php
// Prevent SearchWP from logging searches when logged in
function my_searchwp_skip_logged_in_log( $log, $engine, $search_terms, $number_of_results ) {
return ! is_user_logged_in();
}
add_filter( 'searchwp_log_search', 'my_searchwp_skip_logged_in_log', 10, 4 );
view raw functions.php hosted with ❤ by GitHub

Parameters

Parameter Type Description
$log Boolean

Whether to log the search

$engine String

The engine in use

$search_terms String

The search string

$number_of_results Integer

How many results were found