#7093 closed defect (bug) (fixed)
Groups: still using $_REQUEST['s'] for members search in bp_has_group_members()
Reported by: | garrett-eclipse | Owned by: | dcavins |
---|---|---|---|
Milestone: | 2.6 | Priority: | normal |
Severity: | normal | Version: | 2.5.0 |
Component: | Groups | Keywords: | has-patch |
Cc: |
Description
Hello,
Updating my Buddypress to the latest and going through the updating templates I found that the latest Buddypress breaks the Members Search if ajax is disabled or viewing on non-js.
The search form in bp_directory_members_search_form() was updated to submit the search query via $_REQUESTmembers_search? rather than the previous $_REQUESTs?. But the bp_group_has_members function is still expecting the old $_REQUESTs? so searches don't turn up any results instead they just list all users as though no search was done.
The following code will need to be updated to us the new request term 'members_search';
<?php if ( is_null( $r['search_terms'] ) && ! empty( $_REQUEST['s'] ) ) { $r['search_terms'] = $_REQUEST['s']; }
There may be other instances where it's looking for 's' instead of 'members_search' as the search request.
This isn't evident on a clean install as ajax is enabled and the script intercepts the search and handles the lookup via ajax rather than form submission and the bp_group_has_members method.
Thank you
Attachments (2)
Change History (9)
#2
@
8 years ago
This seems to only affect group members and not general members as the search query arg there is set as follows;
<?php $search_terms_default = null; $search_query_arg = bp_core_get_component_search_query_arg( 'members' ); if ( ! empty( $_REQUEST[ $search_query_arg ] ) ) { $search_terms_default = stripslashes( $_REQUEST[ $search_query_arg ] ); }
So can safely focus on Members loops that are contained within Groups such as the Group Members loop and the Admin Group Members loop.
#3
@
8 years ago
- Component changed from Component - Members to Component - Groups
- Keywords has-patch added
- Summary changed from Group Members search broken on non-ajax sites as it's providing 'members_search' on $_REQUEST but system looks for 's' to Groups: still using $_REQUEST['s'] for members search in bp_has_group_members()
Good catch! Looks like this is a bug-worth-fixing-for-2.6. Patch is attached.
Temporary Workaround
In your members.php template under groups/single/members.php and admin.php under groups/single/admin.php before the bp_group_has_members loop inject the following php workaround;
This will intercept the $_REQUESTmembers_search? search string and apply it to $_REQUESTs? so that the bp_group_has_members loop function is provided the search term.
Cheers