bp_has_members_invitations( array|string $args = '' )

Initialize the community invitations loop.


Description Description

Based on the $args passed, bp_has_invitations() populates buddypress()->invitations->query_loop global, enabling the use of BP templates and template functions to display a list of invitations.


Top ↑

Parameters Parameters

$args

(array|string) (Optional) Arguments for limiting the contents of the invitations loop. Can be passed as an associative array, or as a URL query string. See BP_Invitations_Invitation::get() for detailed information on the arguments. In addition, also supports:

  • 'max'
    (int) Optional. Max items to display. Default: false.
  • 'page_arg'
    (string) URL argument to use for pagination. Default: 'ipage'.

Default value: ''


Top ↑

Return Return

(bool)


Source Source

File: bp-members/bp-members-template.php

function bp_has_members_invitations( $args = '' ) {

	// Get the user ID.
	if ( bp_displayed_user_id() ) {
		$user_id = bp_displayed_user_id();
	} else {
		$user_id = bp_loggedin_user_id();
	}

	// Set the search terms (by default an empty string to get all notifications)
	$search_terms = '';

	if ( isset( $_REQUEST['s'] ) ) {
		$search_terms = stripslashes( $_REQUEST['s'] );
	}

	// Parse the args.
	$r = bp_parse_args( $args, array(
		'id'                => false,
		'inviter_id'        => $user_id,
		'invitee_email'     => false,
		'item_id'           => false,
		'type'              => 'invite',
		'invite_sent'       => 'all',
		'accepted'          => 'pending',
		'search_terms'      => $search_terms,
		'order_by'          => 'date_modified',
		'sort_order'        => 'DESC',
		'page'              => 1,
		'per_page'          => 25,
		'fields'            => 'all',

		// These are additional arguments that are not available in
		// BP_Invitations_Invitation::get().
		'page_arg'          => 'ipage',
	), 'has_members_invitations' );

	// Get the notifications.
	$query_loop = new BP_Members_Invitations_Template( $r );

	// Setup the global query loop.
	buddypress()->members->invitations->query_loop = $query_loop;

	/**
	 * Filters whether or not the user has network invitations to display.
	 *
	 * @since 8.0.0
	 *
	 * @param bool                      $value      Whether or not there are network invitations to display.
	 * @param BP_Notifications_Template $query_loop BP_Members_Invitations_Template object instance.
	 * @param array                     $r          Array of arguments passed into the BP_Members_Invitations_Template class.
	 */
	return apply_filters( 'bp_has_members_invitations', $query_loop->has_invitations(), $query_loop, $r );
}


Top ↑

Changelog Changelog

Changelog
Version Description
8.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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