Last active
April 9, 2019 07:59
-
-
Save xnau/c8af3ff2cf68414134245b31089d15a5 to your computer and use it in GitHub Desktop.
When using Participants Database Combo Multisearch, shows how to make the selections within a multiselect field work as OR terms when global filter mode is enabled.
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 | |
/** | |
* Plugin Name: PDB Multi Field as OR in Filter Search | |
* Description: make the selections within a multiselect field work as OR terms when | |
* global filter mode is enabled | |
*/ | |
add_filter( 'pdb-multisearch_filter_mode', 'xnau_set_multi_field_as_or', 10, 2 ); | |
/** | |
* sets the filter mode for the terms within a multi select field as an OR instead | |
* of AND when the global filter mode is enabled | |
* | |
* @param string $logic OR or AND if the global filter mode is enabled | |
* @param string $fieldname the current field name | |
* @return string must be "AND" or "OR" | |
*/ | |
function xnau_set_multi_field_as_or( $logic, $fieldname ) | |
{ | |
/* this assumes the name of the mult-select field you want treated | |
* as an OR is named "interests" so change that to match your field name | |
*/ | |
if ( $fieldname === 'interests' && $logic === 'AND' ) { | |
$logic = "OR"; | |
} | |
return $logic; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Selecting "OR"/"AND" could be a great extension to the "Combo Multisearch" plugin. Near the functionality of the filter from admin section "List Participants".