2

We have a client's site that has a handful of custom member profile fields, one of them being used for a street address. This particular client would like to perform a keyword search on that address but there's no way to do that from EE. I know we can build a custom search form on the front-end using Solspace User but I was hoping for a control panel add-on that would provide similar functionality.

  • Please select an answer or give more info as to why none of the answers work for you. – Paul Jan 1 '14 at 18:04
1

As far as I know there's nothing native or by way of an addon that provides a better search facility for custom member fields from the control panel. If you specifically wanted this then I'd go with either Profile:Edit or Zoo Visitor which brings your Member data into regular channels for searching, filtering, and sorting via the Edit screen. They make it much easier when dealing with front-end templates and custom member fields too.

1

I am not aware of any addons that offer keyword search of member data.

I'd suggest building this in a normal EE template with jQuery. Protect the page with a conditional to only allow access to the member groups you want to view it and create a quick link to the page from inside the EE control panel.

Set up an EE template to pull all the member data into a table using EE tags or the query module and use a jQuery plugin for the search/filtering... DataTables is a free jQuery plugin that will allow searching/filtering and pagination.

0

I've had some success using a standard GET form and inserting the search term with PHP into a {exp:query} tag on the results template. I then pass the resulting member IDs to Freemember and output the member data with it. You'll need to have access to your SQL database to identify the ID names of your custom member fields.

NB: I don't know whether this method is at risk for SQL injection.

The search form is straightforward:

<form method="get" action="/search">
    <label for="s">Search by Member Screen Name, Affiliation, or Maiden Name</label> <br />
    <input type="search" name="s" id="s" /> <input type="submit" value="Search" />
</form>

Now for the search results template. Suppose you've created two custom member fields called Member Affiliation and Member Maiden Name, and you want a single search form that returns matches to those two fields as well as Screen Name. Open up exp_member_fields in PHPmyAdmin or Sequel Pro, look for those fields, and note the m_field_id associated with them. Suppose you see they have IDs 10 and 11.

Now create a search results template (search/index). Set Allow PHP to Yes and PHP Parsing Stage to Input. Note that Input parsing is less common then Output and it can cause problems if you're using PHP in other ways on the same template.

<?php 
    // retrieve input, if any
    $s =isset($_GET["s"]) ? $_GET["s"] : null;
    ?>

    <h2>Search Results for <em><?php echo $s; ?></em>.</h2>

    {!-- 
    Let's search these fields:
    screen_name:        screen_name (it's already part of exp_members)
    member_affil:       m_field_id_10 
    member_maiden:      m_field_id_11
     --}

    {exp:query limit="100" sql="
       SELECT * FROM exp_member_data 
       JOIN exp_members ON exp_members.member_id = exp_member_data.member_id
       WHERE  (
            screen_name LIKE '%<?php echo $s;?>%')
            OR (m_field_id_10 LIKE '%<?php echo $s;?>%')
            OR (m_field_id_11 LIKE '%<?php echo $s;?>%')
            )
            ORDER BY screen_name
            "}

                {embed="search/_member" the_member_id="{member_id}"}

             {/exp:query}

Finally, the embedded template (search/_member) looks like this:

    {exp:freemember:members member_id="{embed:the_member_id}"}
        <h2>{screen_name}</h2>
        Member Affiliation: {member_affil}
        Member Maiden Name: {member_maiden}

        etc...

    {/exp:freemember:members}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.