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 | |
function afterUserUpdate( $meta_id, $object_id, $meta_key, $_meta_value ) { | |
$userID = $object_id; | |
// $userID was updated | |
} | |
add_action( 'updated_user_meta', 'afterUserUpdate', 10, 4 ); |
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 | |
$common = array( | |
"a", "about", "after", "ago", "all", "am", "an", "and", "any", "are", "aren't", "as", "at", "be", "but", "by", | |
"for", "from", "get", "go", "how", "if", "in", "into", "is", "isn't", "it", "its", "me", "more", "most", "must", | |
"my", "new", "news", "no", "none", "not", "nothing", "of", "off", "often", "old", "on", "once", "only", "or", | |
"other", "our", "ours", "out", "over", "page", "she", "should", "small", "so", "some", "than", "true", "thank", | |
"that", "the", "their", "theirs", "them", "then", "there", "these", "they", "this", "those", "thus", "time", | |
"times", "to", "too", "under", "until", "up", "upon", "use", "users", "version", "very", "via", "want", "was", | |
"way", "web", "were", "what", "when", "where", "which", "who", "whom", "whose", "why", "wide", "will", "with", |
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 | |
function my_searchwp_stopwords( $terms ) { | |
// replace the default SearchWP default common words with 'lorem', 'ipsum', and 'dolor' ONLY | |
$terms = array( 'lorem', 'ipsum', 'dolor' ); | |
return $terms; | |
} | |
add_filter( 'searchwp_stopwords', 'my_searchwp_stopwords' ); |
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 | |
function my_searchwp_sanitize_terms( $enabled, $engine ) | |
{ | |
if( $engine == 'default' ) { | |
// if it's the default engine, use SearchWP's sanitizing | |
return true; | |
} else { | |
// for supplemental engines disable automatic sanitization | |
return false; |
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 | |
// if your visitors commonly misspell "soccer" as "socer" you can fix that for them | |
function my_parse_searchwp_terms( $query, $engine ) { | |
if( false !== strpos( strtolower( $query ), 'socer' ) ) { | |
$query = str_replace( 'socer', 'soccer', strtolower( $query ) ); | |
} | |
return $query; | |
} | |
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 | |
function my_searchwp_posts_per_page( $posts_per_page, $engine, $terms, $page ) | |
{ | |
if( $engine != 'default' ) { | |
// if this is a supplemental search engine, show 20 results per page | |
return 20; | |
} else { | |
// it's the default search engine, return whatever it was originally | |
return $posts_per_page; |
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 | |
add_filter( 'searchwp_in_admin', '__return_true' ); |
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 | |
function my_searchwp_custom_field_keys( $keys ) { | |
$keys[] = 'my_first_meta_key'; | |
$keys[] = 'my_second_meta_key'; | |
return $keys; | |
} | |
add_filter( 'searchwp_custom_field_keys', 'my_searchwp_custom_field_keys', 10, 1 ); |
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 | |
function my_searchwp_exclude( $ids, $engine, $terms ) | |
{ | |
$ids[] = 78; // forcefully exclude post 78 | |
return $ids; | |
} | |
add_filter( 'searchwp_exclude', 'my_searchwp_exclude', 10, 3 ); |
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 | |
function my_searchwp_where( $clause, $engine ) { | |
// manipulate $clause to your liking and return it | |
return $clause; | |
} | |
add_filter( 'searchwp_where', 'my_searchwp_where', 10, 2 ); |