Update search form for member search.
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 20 Mar 2018 12:43:50 +0000 (08:43 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 20 Mar 2018 12:43:50 +0000 (08:43 -0400)
Had this is main member plugin but now moving it into the wmta theme.
This will add to the member search sql when searching the site.
So we can add city name search results.

functions.php
inc/custom.php
style.css

index e692562..9a615be 100644 (file)
@@ -397,3 +397,20 @@ function new_mail_from($old) {
 function new_mail_from_name($old) {
  return 'WMTA';
 }
+
+add_filter('glm-member-db-front-search-query', function( $queryParts ){
+    if ( isset( $_REQUEST['s'] ) && $_REQUEST['s'] ) {
+        $textSearch = addslashes(filter_var($_REQUEST['s'], FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES));
+        $queryParts[] = " (
+                (
+                SELECT true
+                  FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."members
+                 WHERE id = T.member
+                   AND name LIKE '%$textSearch%'
+            )
+            OR T.descr LIKE '%$textSearch%'
+            OR T.city IN ( SELECT id FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "cities WHERE name LIKE '%$textSearch%' )
+        )";
+    }
+    return $queryParts;
+});
index 2221958..ebf488a 100644 (file)
@@ -126,7 +126,7 @@ add_filter('pre_get_posts', 'change_wp_search_size'); // Hook our custom functio
 
 function display_memberfindme_directory() {
        // Show MemberFindMe shortcode from Directory page
-    $_REQUEST['textSearch'] = $_REQUEST['s'];
+    //$_REQUEST['textSearch'] = $_REQUEST['s'];
     $_REQUEST['action'] = 'list';
        $_REQUEST['event_name'] = $_REQUEST['s'];
        echo do_shortcode('[glm-members-list view="grid" ]');
index b99312e..a19548b 100644 (file)
--- a/style.css
+++ b/style.css
@@ -4,7 +4,7 @@ Theme URI: http://underscores.me/
 Author: Underscores.me
 Author URI: http://underscores.me/
 Description: Description
-Version: 1.0.16
+Version: 1.0.17
 License: GNU General Public License v2 or later
 License URI: http://www.gnu.org/licenses/gpl-2.0.html
 Text Domain: wmta