WordPress.org

Forums

Participants Database
Unfiltered search or combine all filters in shortcode? (5 posts)

  1. rwilki
    Member
    Posted 9 months ago #

    Hi.

    I have a form that has several field groups. Some of the field groups ask the same basic question because we're trying to get subset information, like a directory.

    Subset 1: Name
    Subset 2: Name
    Subset 3: Name
    Subset 4: Name

    I would like people to be able to search for "Name", and get any record that is entered in a "Name" field irregardless of the subset number.

    So, my question is is there a way for your shortcode to include a global, unfiltered search? People aren't going to know which subset to use as a filter. Or am I going to have to add all my field labels into a long shortcode string, so that essentially the search is filtering everything?

    Maybe my naming convention is wrong for my fields and there's a wholly different approach.

    Thanks so much for the most awesome plugin in the wp repository!

    https://wordpress.org/plugins/participants-database/

  2. xnau
    Member
    Plugin Author

    Posted 9 months ago #

    Bob,

    It can be done using a shortcode filter, because you can combine several conditions using an "or"operator sot if any one of them is true, the record will be included in the result. You can't do this with the built-in search control for your users, but if you were to make a custom search control that submitted a search term to another page with the shortcode in it, you could incorporate that term into the shortcode as a variable:

    <?php
    $term = '';
    if (isset($_GET['search_term'])) $term = $_GET['search_term'];
    echo do_shortcode('[pdb_list filter="name1=' . $term . '|name2=' . $term . '"]');
    ?>
  3. rwilki
    Member
    Posted 9 months ago #

    Thanks for your reply.

    So, the plugin cannot do an unfiltered search out of the box; meaning to have the search input field search all fields without the select input beneath?

    I assume the example you're showing is for a template?
    Would this be the shortcode? [pdb_list filter="name1,name2,name3"]

    Just not following how I can customize the search function from what normally displays.

  4. rwilki
    Member
    Posted 9 months ago #

    Roland, in order to have a custom search control, do I need to create an API or can I create a template and hardcode in PHP similar to your example and use shortcode to present a search box which will search for all of my fields?

    I tried to circumvent the column select drop-down with CSS, but as you know the search function still requires it.

  5. xnau
    Member
    Plugin Author

    Posted 9 months ago #

    There are several ways to do it, I am suggesting a simple method that only requires that you create a search form, the uses that submitted data to contstruct a plugin shortcode, then execute it. If you look at the documentation on how to use the shortcode filter, you'll see how to filter on multiple fields. Basically, you're creating a template that builds that filter string dynamically into the shortcode, then executes it.

Reply

You must log in to post.

About this Plugin

  • Participants Database
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.