Member search into group does not work before filter it
-
Hi,
I have problem searching members into a group page.
When I enter some text into members_search field, and than press submit button, the page returns all the users of the group instead of filter it.
With developer tools I’ve seen that “search_terms” POST parameter is not set with submit push ajax request.But, if I change order setting from select box (for example from last_joined to alphabetical or viceversa), the new ajax request have the search_terms parameter inside it…and so results are correctly filtered!
Seems that submit button don’t pass search text parameter.
Have you experienced that?
-
What theme are you using? I wonder if the JS that you’re using is out of sync with the search template.
I have a multisite installation.
Plugin does not work with both Magnum and Optimizer PRO installed.I’m unable to test with the proprietary Magnum theme, but with the free version of Optimizer, I’m unable to reproduce the problem. Group member searches are working as expected: https://postimg.org/image/axag5nsjr/
Here’s the relevant part of BP’s JavaScript: https://buddypress.trac.wordpress.org/browser/tags/2.9.2/src/bp-templates/bp-legacy/js/buddypress.js?marks=863#L848 The first thing to check is that your theme is actually requiring buddypress.js (or buddypress.min.js) out of the buddypress theme directory; if not, it’s possible you’re running an out-of-date version bundled with a theme or something. Then, you may need to deminimize (or set
define( 'SCRIPT_DEBUG', true );
) to debug. Then, check to see whether this bit of script is actually able to find thesearch_terms
element. It’s possible that your theme, or some other plugin, is modifying the markup so that the selectors or the element hierarchy has changed.Thank boonebgorges.
First of all buddypress.min.js is correctly loaded in the page and it is not part of the theme but the plugin is installed indipendently.I’m using version 2.8.2. I load not minified js to debug it. Look at this part of code:
if ( target.attr('type') === 'submit' ) { css_id = jq('.item-list-tabs li.selected').attr('id').split( '-' ); object = css_id[0]; template = null; search_terms = target.parent().find( '#' + object + '_search' ).val(); // The Group Members page specifies its own template if ( event.currentTarget.className === 'groups-members-search' ) { object = 'group_members'; template = 'groups/single/members'; } bp_filter_request( object, jq.cookie('bp-' + object + '-filter'), jq.cookie('bp-' + object + '-scope') , 'div.' + object, search_terms, 1, jq.cookie('bp-' + object + '-extras'), null, template ); return false; }
when it create “item-list-tabs li.selected” class to populate css_id array it takes the first one div in DOM with that class, and the corresponding array is [home, groups, li]. So it searches for #home_search to set value of search_terms…but home_search element doesn’t exists on the page!
To correctly search terms it should search for #members_search. What can I do? I don’t want to hardcode some javascript ๐
@scribit – Thanks for following up. We are getting closer ๐
Do you have any idea why the
home
element has theselected
class? Does this mean that, when you view the group nav tabs, both Home and Selected have the “current” styling? BuddyPress doesn’t do this out of the box, so I wonder if perhaps there’s something in your theme that’s causing it to happen. Figuring out what’s causing that extraselected
class, and disabling it, would probably fix the problem you’ve described.It is also the case that this JavaScript is quite fragile. I wonder if we could use the body class or something like that as a more reliable way of deterimining which tab we’re looking at. On the other hand, the JS for the new, upcoming template packs (bp-nouveau) is totally different here, so maybe it’s not worth fixing.
Here the piece of page on which there is the element with “selected” class (HOME button).
Home button is a standard Buddypress element. I don’t add it for myself.Removing the selected class from Developer tools, and submitting the search form, it works but don’t use the “ajax mode”: It reloads the page adding search term as GET parameter (?members_search=test&members_search_submit=Cerca) and retrieving the correct results.
My tinypic image has been removed from last post. I paste the DOM relative code:
<div class="item-list-tabs no-ajax" id="object-nav" aria-label="Navigazione gruppo primaria" role="navigation"> <ul> <li id="home-groups-li" class="current selected"> <a id="home" href="http://xxxxxxxxx.xxx/gruppi/apulo-lucana/">Home</a> </li> <li id="admin-groups-li"> <a id="admin" href="http://xxxxxxxxx.xxx/gruppi/apulo-lucana/admin/">Gestisci</a> </li> </ul> </div>
The site is in italian (“Gestisci” stands for “Manage” and “Navigazione gruppo primaria” for “Main group navigation”)
Thanks for sharing the markup. So are there *two* separate
list-item-tabs
elements on the page? I don’t see aMembers
nav item here.Yes, the other one is this:
<div class="item-list-tabs" id="subnav" aria-label="Navigazione gruppo secondaria" role="navigation"> <ul> <li class="groups-members-search" role="search"> <form action="" method="get" id="search-members-form"> <label for="members_search"><input type="text" name="members_search" id="members_search" placeholder="Cerca membri..."></label> <input type="submit" id="members_search_submit" name="members_search_submit" value="Cerca"> </form> </li> <li id="group_members-order-select" class="last filter"> <label for="group_members-order-by">Ordinato per:</label> <select id="group_members-order-by"> <option value="last_joined">Nuovi</option> <option value="first_joined">Il piรน vecchio</option> <option value="alphabetical">Alfabetico</option> </select> </li> </ul> </div>
and includes the search form.
Ah, so that is the issue. Something in your theme, or another one of your plugins, is causing the navigation to be rendered two times. If you’re able to switch to Twenty Sixteen or another default WP theme, you could verify that the theme is the culprit.
In the meantime, I’m not quite sure how to address the problem. Is it important for your purposes that
Home
isselected
in this view? If not, it may be possible to drop in a bit of JavaScript that’ll unselect it, which will probably cause the search to work again.Thank you Boone for your patience ๐
I’ve removed completely the main “item-list-tabs” div (the first one in this topic). Now the search works but, as I said yesterday, it is not an ajax search and report the search terms as GET parameter in the url bar (refreshing page during search).
It could also be fine but, in this situation, the order combobox no longer filter the results (maybe it ignore search term in GET parameters). Changing the order it loads every members again.Thanks for your patience as well ๐
I’m unsure how to debug the AJAX issue further without full access to your installation. If you do manage to figure out what’s wrong there, please drop a note here with your findings.
In the meantime, you may be able to work around this whole thing by adding the
no-ajax
class to theitem-list-tabs
element containing the search. Obviously, this is not ideal, but at least it should fix the problem with the incomplete AJAX call.What should this modification do?
I put no-ajax class but I continue to have:
– text search not using ajax
– order combobox using ajax> text search not using ajax
This is what it should do. The original problem in this thread was that group members search didn’t work at all, because it wasn’t sending the contents of the search box. With AJAX disabled, at least the search should work.
Hi,
I have the exact same issue with the template we are using ie that the text search is triggered by selecting the from the filter dropdown.
We are using the theme Ester.In your post above you mention to add no-ajax class โ in which page template should this be added?
I tried to add it to groups/single/home.php but it doesnโt work.Thanks
johkUnfortunately I have to insert the no-ajax class directly in one of the plugin files (not in the template).
If I remember correctly the file is: bp-groups/bp-groups-template.php
in the function: bp_groups_members_template_part
- You must be logged in to reply to this topic.