BuddyPress Group Hierarchy

A plugin for BuddyPress that allows groups to belong to other groups

About

Features:

  • Unlimited group hierarchy – nest groups as deeply as you like
  • Per-group control over subgroups – create a site with “sections,” or keep certain groups free of user-created subgroups
  • Toggle top-level group creation – keep as much control over the hierarchy as your needs dictate
  • Expandable tree display that can replace — or supplement — the main group list

Language support for:

  • Spanish translation generously provided by _DorsVenabili
  • Russian translation generously provided by Roman
  • Slovak translation generously provided by Branco, (WebHostingGeeks.com)
  • Danish translation generously provided by Mort3n
  • French translation generously provided by Mecanographik
  • Brazilian Portugese translation generously provided by stickFinger
  • Dutch translation generously provided by Zé Vandenhoeck
  • Italian translation generously provided by Stefano Colarelli

FAQ

Does privacy or status propagate from group to subgroup?

— No. The plugin creates a hierarchy of group URLs, but does not put restrictions on the subgroup.

Are group members automatically added to a subgroup?

— No. I don’t know how you will want to use subgroups, so no assumptions have been made.

If I restrict new groups to member or admins, can a subgroup be made with more lenient restrictions?

— Yes. Restrictions affect only the group to which they are applied. Subgroups can themselves be more or less restrictive.

Do activity stream messages propagate up (from child to parent) or down (from parent to child)?

No. This function was available (without an interface) but was removed, possibly for use in a forthcoming project.

API for Developers

Filters

bp_group_hierarchy_directory_order_sort

[coming soon]

bp_group_hierarchy_available_parent_groups

Filter this array to limit the groups presented as possible parents when creating a new group

Parameters:

  • $display_groups – array of available, active groups
  • $group – BP_Group_Hierarchy object of the group being created or edited
bp_group_hierarchy_subgroup_permission_options

Filter this array to add or remove subgroup creation permission options

Parameters:

  • $permission_options – array of available permission options
  • $group – BP_Group_Hierarchy object of the group being created or edited
bp_group_hierarchy_enforce_subgroup_permission_{your permission name}

Return TRUE to allow a user to create subgroups; allows custom subgroup creation permission options

Parameters:

  • $user_id – ID of the user seeking to add child group
  • $group_id – ID of the group user is trying to use as parent

Actions

bp_group_hierarchy_route_requests

Run after BuddyPress is initialized, but before it makes page routing decisions. Can be used for setting cookies and sending params to pages that don’t otherwise accept them.

Functions for theme developers

No parameters are needed for these functions when run in the loop.

bp_group_hierarchy_full_name()

Echoes the name of the current group and all its ancestors.
Use bp_group_hierarchy_get_full_name() for more advanced options.

bp_group_hierarchy_breadcrumbs()

Echoes a string of links to the current group and all its ancestors.
Use bp_group_hierarchy_get_breadcrumbs() for more advanced options.

bp_group_hierarchy_get_breadcrumbs( $separator = ‘ | ‘, $group = null )

Returns a string of links to the current group and all its ancestors.

bp_group_hierarchy_has_subgroups()

Returns the number of subgroups, including 0 if the group has none.

bp_group_hierarchy_get_subgroups()

Returns an array containing the IDs of the direct descendants of the current group.

bp_group_hierarchy_has_parent()

Returns the ID of the parent group, or 0 if the group is at the top level.

bp_group_hierarchy_get_parents()

Returns an array containing the IDs of the ancestors of the current group.

Functions for plugin developers or integrators

groups_hierarchy_create_group( array $params )

A hierarchy-aware wrapper for the BuddyPress groups_create_group function. Can be used the same way, but also accepts a parent_id parameter to specify a new group’s parent group.