BP_Groups_Group::get_membership_requests( int $group_id, int|null $limit = null, int|null $page = null )

Get outstanding membership requests for a group.

Description

Parameters

$group_id

(int) (Required) ID of the group.

$limit

(int|null) (Optional) Max number of results to return. Default: null (no limit).

Default value: null

$page

(int|null) (Optional) Page offset of results returned. Default: null (no limit).

Default value: null

Return

(array)

  • 'requests'
    (array) The requested page of located requests.
  • 'total'
    (int) Total number of requests outstanding for the group.

Source

File: bp-groups/classes/class-bp-groups-group.php

	public static function get_membership_requests( $group_id, $limit = null, $page = null ) {
		global $wpdb;

		if ( !empty( $limit ) && !empty( $page ) ) {
			$pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
		}

		$bp = buddypress();

		$paged_requests = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 0 AND inviter_id = 0{$pag_sql}", $group_id ) );
		$total_requests = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 0 AND inviter_id = 0", $group_id ) );

		return array( 'requests' => $paged_requests, 'total' => $total_requests );
	}

Changelog

Changelog
Version Description
BuddyPress 1.6.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.