groups_invite_user( array|string $args = '' )

Invite a user to a group.

Parameters Parameters


(array|string) (Optional) Array of arguments.

  • 'user_id'
    (int) ID of the user being invited.
  • 'group_id'
    (int) ID of the group to which the user is being invited.
  • 'inviter_id'
    (int) Optional. ID of the inviting user. Default: ID of the logged-in user.
  • 'date_modified'
    (string) Optional. Modified date for the invitation. Default: current date/time.
  • 'content'
    (string) Optional. Message to invitee.
  • 'send_invite'
    (bool) Optional. Whether the invitation should be sent now. Default: false.

Default value: ''

Top ↑

Return Return

(bool) True on success, false on failure.

Source Source

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

function groups_invite_user( $args = '' ) {

	$r = bp_parse_args( $args, array(
		'user_id'       => false,
		'group_id'      => false,
		'inviter_id'    => bp_loggedin_user_id(),
		'date_modified' => bp_core_current_time(),
		'content'       => '',
		'send_invite'   => 0
	), 'groups_invite_user' );

	$inv_args = array(
		'user_id'       => $r['user_id'],
		'item_id'       => $r['group_id'],
		'inviter_id'    => $r['inviter_id'],
		'date_modified' => $r['date_modified'],
		'content'       => $r['content'],
		'send_invite'   => $r['send_invite']

	// Create the unsent invitataion.
	$invites_class = new BP_Groups_Invitation_Manager();
	$created       = $invites_class->add_invitation( $inv_args );

	 * Fires after the creation of a new group invite.
	 * @since 1.0.0
	 * @param array    $r       Array of parsed arguments for the group invite.
	 * @param int|bool $created The ID of the invitation or false if it couldn't be created.
	do_action( 'groups_invite_user', $r, $created );

	return $created;

Top ↑

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.