groups_get_invites_for_user( int $user_id, int|bool $limit = false, int|bool $page = false, string|array|bool $exclude = false )

Get group objects for groups that a user is currently invited to.


Description Description


Parameters Parameters

$user_id

(Required) ID of the invited user.

$limit

(Optional) Limit to restrict to.

Default value: false

$page

(Optional) Page offset of results to return.

Default value: false

$exclude

(Optional) Array of comma-separated list of group IDs to exclude from results.

Default value: false


Top ↑

Return Return

(array)

  • 'groups'
    (array) Array of groups returned by paginated query.
  • 'total'
    (int) Count of groups matching query.


Top ↑

Source Source

File: bp-groups/bp-groups-functions.php

function groups_get_invites_for_user( $user_id = 0, $limit = false, $page = false, $exclude = false ) {
	if ( empty( $user_id ) ) {
		$user_id = bp_loggedin_user_id();
	}

	$group_ids = groups_get_invited_to_group_ids( $user_id );

	// Remove excluded groups.
	if ( $exclude ) {
		$group_ids = array_diff( $group_ids, wp_parse_id_list( $exclude ) );
	}

	// Avoid passing an empty array.
	if ( ! $group_ids ) {
		$group_ids = array( 0 );
	}

	// Get a filtered list of groups.
	$args = array(
		'include'     => $group_ids,
		'show_hidden' => true,
		'per_page'    => $limit,
		'page'        => $page,
	);
	$groups = groups_get_groups( $args );

	return array( 'groups' => $groups['groups'], 'total' => groups_get_invite_count_for_user( $user_id ) );
}

Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.