Add search within group Members
-
I think I mentioned this before, but quite a long time ago, so wondering if any further ideas have emerged about getting the advanced search to work for Group Members.
It would seem to be quite logical to allow the same search facilities for Members and Group Members, though this is not easily allowed for by BuddyPress (and not at all by bp nouveau which produced completely different implementations of the two forms).
I had some difficulty and some success … in fact it worked, except where nothing matches the filter…
The modifications necessary were
in bp-profile-search:
bps-templates47.php actions ll17-18:$dirs = bps_directories (); $F->action = $dirs[$meta['action']]->link;
change to:
if (bp_is_group_members()){ $F->action = "?"; }else{ $F->action = $dirs[$meta['action']]->link; }
bps-search.php l.50 change from:
if ($object != 'members' && $object != '') return $qs; if (bps_active_form () === false) return $qs;
to:
//allow the filter to apply to certain forms.. switch ($object) { case 'members' : case 'group_members' : if (bps_active_form () === false) return $qs; break; default: return $qs; }
and add to top of bps-form.php:
/* add also to group member directory */ add_action ('bp_before_group_members_content', 'bps_add_form'); add_action ('bp_before_group_members_content', 'bps_display_filters');
Now the difficulty is with BuddyPress core, there was a change to BuddyPress bp-groups-functions.php (was l.658) change to:
$members = new BP_Group_Member_Query( $r);
otherwise ‘include’ filter is lost.
But that’s not the end of story because BP_Group_Member_Query also has an override for get_include_ids and none of this area is readily filterable.Then, when no results are found for the query, a whole range of errors are then logged along the lines of:
Notice: Undefined property: stdClass::$user_id in wp-content/plugins/buddypress/bp-groups/bp-groups-template.php on line 4107
Stack trace:
1. {main}() index.php:0
2. require() index.php:17
3. require_once() wp-blog-header.php:19
4. include() wp-includes/template-loader.php:74
5. get_template_part($slug = *uninitialized*, $name = *uninitialized*) wp-content/themes/twentysixteen/page.php:23
6. locate_template($template_names = *uninitialized*, $load = *uninitialized*, $require_once = *uninitialized*) wp-includes/general-template.php:167
7. load_template($_template_file = *uninitialized*, $require_once = *uninitialized*) wp-includes/template.php:647
8. require() wp-includes/template.php:690
9. the_content($more_link_text = *uninitialized*, $strip_teaser = *uninitialized*) wp-content/themes/twentysixteen/template-parts/content-page.php:20
10. apply_filters($tag = *uninitialized*, $value = *uninitialized*) wp-includes/post-template.php:240
11. WP_Hook->apply_filters($value = *uninitialized*, $args = *uninitialized*) wp-includes/plugin.php:203
12. bp_replace_the_content($content = *uninitialized*) wp-includes/class-wp-hook.php:298
13. apply_filters($tag = *uninitialized*, $value = *uninitialized*) wp-content/plugins/buddypress/bp-core/bp-core-theme-compatibility.php:761
14. WP_Hook->apply_filters($value = *uninitialized*, $args = *uninitialized*) wp-includes/plugin.php:203
15. BP_Groups_Theme_Compat->single_content(*uninitialized*) wp-includes/class-wp-hook.php:298
16. bp_buffer_template_part($slug = *uninitialized*, $name = *uninitialized*, $echo = *uninitialized*) wp-content/plugins/buddypress/bp-groups/classes/class-bp-groups-theme-compat.php:265
17. bp_get_template_part($slug = *uninitialized*, $name = *uninitialized*) wp-content/plugins/buddypress/bp-core/bp-core-template-loader.php:338
18. bp_locate_template($template_names = *uninitialized*, $load = *uninitialized*, $require_once = *uninitialized*) wp-content/plugins/buddypress/bp-core/bp-core-template-loader.php:61
19. load_template($_template_file = *uninitialized*, $require_once = *uninitialized*) wp-content/plugins/buddypress/bp-core/bp-core-template-loader.php:155
20. require() wp-includes/template.php:690
21. bp_groups_members_template_part() wp-content/plugins/buddypress/bp-templates/bp-legacy/buddypress/groups/single/home.php:117
22. bp_get_template_part($slug = *uninitialized*, $name = *uninitialized*) wp-content/plugins/buddypress/bp-groups/bp-groups-template.php:4505
23. bp_locate_template($template_names = *uninitialized*, $load = *uninitialized*, $require_once = *uninitialized*) wp-content/plugins/buddypress/bp-core/bp-core-template-loader.php:61
24. load_template($_template_file = *uninitialized*, $require_once = *uninitialized*) wp-content/plugins/buddypress/bp-core/bp-core-template-loader.php:155
25. require() wp-includes/template.php:690
26. bp_group_member_domain() wp-content/plugins/buddypress/bp-templates/bp-legacy/buddypress/groups/single/members.php:52
27. bp_get_group_member_domain() wp-content/plugins/buddypress/bp-groups/bp-groups-template.php:4089It looks like the global $members_template is not set up properly at this point but then the code gets called anyway.
So just reaching out for thoughts..
- The topic ‘Add search within group Members’ is closed to new replies.