Resources

https://github.com/buddypress/buddypress/blob/master/src/bp-groups/bp-groups-functions.php

Functions

Fetch a single group object
function groups_get_group( $group_id )

Retrieve group by a given field.
function bp_get_group_by( $field, $value )

Retrieve a Group.
function bp_get_group( $group = false )

Group Creation, Editing & Deletion

Create a group
function groups_create_group( $args = ” )

Edit the base details for a group
function groups_edit_base_group_details( $args = array() )

Edit the base details for a group
function groups_edit_group_settings( $group_id, $enable_forum, $status, $invite_status = false, $parent_id = false )

Delete a group and all of its associated metadata.
function groups_delete_group( $group_id )

Check a group status (eg ‘private’) against the list of registered statuses
function groups_is_valid_status( $status )

Provide a unique, sanitized version of a group slug.
function groups_check_slug( $slug )

Get slug from a group.
function groups_get_slug( $group )

Get a group ID by its slug.
function groups_get_id( $group_slug )

Get a group ID by checking against old (not currently active) slugs
function groups_get_id_by_previous_slug( $group_slug )

User Actions

Remove a user from a group
function groups_leave_group( $group, $user_id = 0 )

Add a user to a group.
function groups_join_group( $group, $user_id = 0 )

Update the last_activity meta value for a given group
function groups_update_last_activity( $group = 0 )

General Group Functions

Get a list of group administrators
function groups_get_group_admins( $group_id )

Get a list of group moderators
function groups_get_group_mods( $group_id )

Fetch the members of a group
function groups_get_group_members( $args = array() )

Get the member count for a group
function groups_get_total_member_count( $group, $skip_cache = false )

Group Fetching, Filtering & Searching

Get a collection of groups, based on the parameters passed
function groups_get_groups( $args = ” )

Get the total group count for the site
function groups_get_total_group_count( $skip_cache = false )

Get the IDs of the groups of which a specified user is a member
function groups_get_user_groups( $user_id = 0, $pag_num = 0, $pag_page = 0 )

Get a list of groups of which the specified user is a member
function bp_get_user_groups( $user_id, $args = array() )

Get the count of groups of which the specified user is a member
function groups_total_groups_for_user( $user_id = 0 )

Get the BP_Groups_Group object corresponding to the current group
function groups_get_current_group()

Group Avatars

Generate the avatar upload directory path for a given group
function groups_avatar_upload_dir( $group_id = 0 )

Group Member Status Checks

Get the Group roles
function bp_groups_get_group_roles()

Check whether a user is an admin of a given group
function groups_is_user_admin( $user_id, $group_id )

Check whether a user is a mod of a given group
function groups_is_user_mod( $user_id, $group_id )

Check whether a user is a member of a given group
function groups_is_user_member( $user_id, $group_id )

Check whether a user is banned from a given group
function groups_is_user_banned( $user_id, $group_id )

Check whether a user has an outstanding invitation to a group
function groups_is_user_invited( $user_id, $group_id, $type = ‘sent’ )

Check whether a user has a pending membership request for a group
function groups_is_user_pending( $user_id, $group_id )

Is the specified user the creator of the group?
function groups_is_user_creator( $user_id, $group_id )

Group Invitations

Get group objects for groups that a user is currently invited to
function groups_get_invites_for_user( $user_id = 0, $limit = false, $page = false, $exclude = false )

Get the total group invite count for a user
function groups_get_invite_count_for_user( $user_id = 0 )

Get an array of group IDs to which a user is invited
function groups_get_invited_to_group_ids( $user_id = 0 )

Invite a user to a group
function groups_invite_user( $args = ” )

Uninvite a user from a group
function groups_uninvite_user( $user_id, $group_id, $inviter_id = false )

Process the acceptance of a group invitation
function groups_accept_invite( $user_id, $group_id )

Reject a group invitation.
function groups_reject_invite( $user_id, $group_id, $inviter_id = false )

Delete a group invitation
function groups_delete_invite( $user_id, $group_id, $inviter_id = false )

Send some or all pending invites by a single user to a specific group
function groups_send_invites( …$args )

Get IDs of users with outstanding invites to a given group
function groups_get_invites_for_group( $user_id, $group_id, $sent = null )

Get invitations to a given group filtered by arguments
function groups_get_invites( $args = array() )

Check to see whether a user has already been invited to a group
function groups_check_user_has_invite( $user_id, $group_id, $type = ‘sent’ )

Check to see whether a user has already been invited to a group by a particular user
function groups_check_has_invite_from_user( $user_id, $group_id, $inviter_id = false, $type = ‘sent’ )

Delete all invitations to a given group
function groups_delete_all_group_invites( $group_id )

Group Promotion & Banning

Promote a member to a new status within a group
function groups_promote_member( $user_id, $group_id, $status )

Demote a user to ‘member’ status within a group
function groups_demote_member( $user_id, $group_id )

Ban a member from a group
function groups_ban_member( $user_id, $group_id )

Unban a member from a group.
function groups_unban_member( $user_id, $group_id )

Group Removal
function groups_remove_member( $user_id, $group_id )

Group Membership

Create a group membership request
function groups_send_membership_request( …$args )

Accept a pending group membership request
function groups_accept_membership_request( $membership_id, $user_id = 0, $group_id = 0 )

Reject a pending group membership request
function groups_reject_membership_request( $membership_id, $user_id = 0, $group_id = 0 )

Delete a pending group membership request
function groups_delete_membership_request( $membership_id, $user_id = 0, $group_id = 0 )

Get group membership requests filtered by arguments
function groups_get_requests( $args = array() )

Check whether a user has an outstanding membership request for a given group
function groups_check_for_membership_request( $user_id, $group_id )

Get an array of group IDs to which a user has requested membership
function groups_get_membership_requested_group_ids( $user_id = 0 )

Get an array of group IDs to which a user has requested membership
function groups_get_membership_requested_user_ids( $group_id = 0 )

Accept all pending membership requests to a group
function groups_accept_all_pending_membership_requests( $group_id = 0 )

Group Meta

Delete metadata for a group
function groups_delete_groupmeta( $group_id, $meta_key = false, $meta_value = false, $delete_all = false )

Get a piece of group metadata
function groups_get_groupmeta( $group_id, $meta_key = ”, $single = true )

Update a piece of group metadata
function groups_update_groupmeta( $group_id, $meta_key, $meta_value, $prev_value = ” )

Add a piece of group metadata
function groups_add_groupmeta( $group_id, $meta_key, $meta_value, $unique = false )

Group Cleanup Functions

Delete all group membership information for the specified user
function groups_remove_data_for_user( $user_id )

Deletes user group data on the ‘delete_user’ hook
function bp_groups_remove_data_for_user_on_delete_user( $user_id )

Update orphaned child groups when the parent is deleted
function bp_groups_update_orphaned_groups_on_group_delete( $group )

Group Types

Output the slug of the Group type taxonomy
function bp_group_type_tax_name()

Returns labels used by the Group type taxonomy
function bp_get_group_type_tax_labels()

Returns arguments used by the Group type taxonomy
function bp_get_group_type_tax_args()

Register the Group Types taxonomy
function bp_groups_register_group_type_taxonomy( $taxonomies = array() )

Fire the ‘bp_groups_register_group_types’ action
function bp_groups_register_group_types()

Extend generic Type metadata schema to match Group Type needs
function bp_get_group_type_metadata_schema( $schema = array(), $taxonomy = ” )

Registers the Group type metadata
function bp_register_group_type_metadata()

Register a group type
function bp_groups_register_group_type( $group_type, $args = array() )

Get a list of all registered group type objects
function bp_groups_get_group_types( $args = array(), $output = ‘names’, $operator = ‘and’ )

Retrieve a group type object by name
function bp_groups_get_group_type_object( $group_type )

Only gets the group types registered by code
function bp_get_group_types_registered_by_code()

Generates missing metadata for a type registered by code
function bp_set_registered_by_code_group_type_metadata( $metadata = array(), $type = ” )

Insert group types registered by code not yet saved into the database as WP Terms
function bp_insert_group_types_registered_by_code()

Set type for a group
function bp_groups_set_group_type( $group_id, $group_type, $append = false )

Get type for a group
function bp_groups_get_group_type( $group_id, $single = true, $use_db = true )

Remove type for a group
function bp_groups_remove_group_type( $group_id, $group_type )

Check whether the given group has a certain group type
function bp_groups_has_group_type( $group_id, $group_type )

Get the “current” group type, if one is provided, in group directories
function bp_get_current_group_directory_type()

Delete a group’s type when the group is deleted
function bp_remove_group_type_on_group_delete( $group_id = 0 )

Finds and exports group membership data associated with an email address
function bp_groups_memberships_personal_data_exporter( $email_address, $page )

Finds and exports data on pending group membership requests associated with an email address
function bp_groups_pending_requests_personal_data_exporter( $email_address, $page )

Finds and exports data on pending group invitations sent by a user associated with an email address
function bp_groups_pending_sent_invitations_personal_data_exporter( $email_address, $page )

Finds and exports data on pending group invitations received by a user associated with an email address
function bp_groups_pending_received_invitations_personal_data_exporter( $email_address, $page )

USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.

Comments

Your email address will not be published. Required fields are marked *