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.


Parameters Parameters

$user_id

(int) (Required) ID of the invited user.

$limit

(int|bool) (Optional) Limit to restrict to.

Default value: false

$page

(int|bool) (Optional) Page offset of results to return.

Default value: false

$exclude

(string|array|bool) (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.


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,
	);

	return groups_get_groups( $args );
}


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.