You can try dropping this in your theme’s functions.php. I ripped it out of the extension.php file from the plugin.
if(bp_is_groups_component() && bp_current_action() == '') {
add_filter( 'groups_get_groups', 'bp_group_hierarchy_get_groups_tree', 10, 2 );
}
Let me know how that works for you.
Good news and bad news. It actually does work to suppress the child groups from the Groups Directory page (very cool!). However, when I select the parent group from the list, it is throwing this error:
Fatal error: Call to undefined function bp_core_setup_globals() in /home/content/28/8075728/html/examplesite/wp-content/plugins/bp-group-hierarchy/bp-group-hierarchy-classes.php on line 22
Seems like you are right on top of it though – any idea on what’s going on with that error?
Thank you for getting us a step closer!!!
It looks like just sitting in the functions.php
file makes bp_current_action()
fire too soon, at least on some pages.
Yep – that seems to be it. And the old workaround is no longer working. So wrap the whole thing in a function that’s called on init
. EG:
add_action('init', 'restrict_group_list');
function restrict_group_list() {
if(bp_is_groups_component() && bp_current_action() == '') {
add_filter( 'groups_get_groups', 'bp_group_hierarchy_get_groups_tree', 10, 2 );
}
}
Let me know how that works for you!
That did the trick – works perfect!!! Thank you 1000x!