• Resolved mrwassen

    (@dwl003)


    Hi,

    Great plugin. Since I needed search capabilities I purchased the meta fields search add-on. However, it turned out to work a bit differently than expected.

    I was hoping to be able to configure a single search bar that could search across multiple profile fields. For example, if I have 3 meta fields “Personal Interests”, “Hobbies” and “Services Offered” I need a single bar that returns matches on any of those 3 fields when a single search term is specified, e.g. “electronics”.

    Is there any way this could be achieved with the 2 plugins? (including a not too complex coding approach).

    Thanks,

    Dennis

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter mrwassen

    (@dwl003)

    Hi Sarah,

    I made a small modification to your plugin that allows me to achieve the “single term search” as I have dubbed it. The mod is a bit crude and does not pretend to fully integrate with all of the other DUD features, but I don’t think that would be too hard to do that if you wanted to make it available as part of the core functionality. In any case, here are the changes:

    1) Add a new optional input to the dud_build_directory_query() function in core.php as follows (last argument):

    function dud_build_directory_query(..., $single_term=NULL) {}

    2) At the very end of the function right before the query syntax is returned, add this statement:

    if (isset($single_term)) {$user_sql = 'SELECT DISTINCT bp.user_id from wp_bp_xprofile_data bp INNER JOIN wp_users wp ON wp.id = bp.user_id WHERE bp.value LIKE "%' . $single_term . '%" ORDER BY wp.display_name';                
           } 
    return $user_sql;

    3) Add the following argument in DynamicUserDirectory() in the 2 instances where dud_build_directory_query() is called (lines 317 and 2033 in v. 1.8), also as last argument:

    $user_sql = dud_build_directory_query(..., $_GET['term']);

    Now on the page having the [DynamicUserDirectory] shortcode, e.g. http://www.mydomain/member-directory I can add an input field and button which calls the page with a URL argument containing the search term, i.e.

    http://www.mydomain/member-directory?term=electronics

    The directory will then be displayed filtered for all BP (xprofile) fields containing the string “electronics”.

    A final version of this should probably only search fields that are defined in the DUD settings + a few other refinements I am sure.

    Please let me know your thoughts.

    Thanks

    Dennis

    • This reply was modified 7 years, 3 months ago by mrwassen.
    • This reply was modified 7 years, 3 months ago by mrwassen.
    Plugin Author Sarah Giles

    (@sarah_dev)

    Hi Dennis,

    Sorry to hear the meta fields search wasn’t quite what you were looking for. The good news is that I am planning to send out an update to the add-on in the next month or two that will add the feature you are requesting.

    However, I will be sending out a previously scheduled update to DUD and its add-ons first. You may want to wait on running those so they won’t override your local changes.

    Best Regards,
    Sarah

    Thread Starter mrwassen

    (@dwl003)

    That’s music to my ears – thanks! Just last night I was trying to work out the sorting by display name which was broken with my hack. Now I will just wait until that version comes out instead. (and not install any updates that come out in the meantime).

    Thanks for your help!

    Dennis

    Thread Starter mrwassen

    (@dwl003)

    One other feature suggestion that would be very helpful:

    I made another mod which displays a clickable email icon next to each entry when listing out the directory. When clicked, the private message compose form comes up with the “To:” user id pre-populated (this is a standard BP URL for compose) for all users except the logged in user. The logged in user instead gets a link saying “Edit your profile”.

    These are to me very useful, but rather than asking you to add something like this, would it be possible to introduce the concept of having a dud folder under the child theme folder similar to what buddypress as a plugin provides? This way, an alternate version of the plugin files could be maintained here and not be impacted when the plugin itself is upgraded.

    Thanks in advance for your consideration.

    Dennis

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Search across fields’ is closed to new replies.