bp_members_invitations_get_hash( $invitation )

Get hash based on details of a membership invitation and the inviter.


Parameters Parameters

(BP_Invitation) (Required) object $invitation Invitation to create hash from.


Top ↑

Return Return

(string) $hash Calculated sha1 hash.


Source Source

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

function bp_members_invitations_get_hash( BP_Invitation $invitation ) {
	$hash = false;

	if ( ! empty( $invitation->id ) ) {
		$inviter_ud = get_userdata( $invitation->inviter_id );
		if ( $inviter_ud ) {
			/*
			 * Use some inviter details as part of the hash so that invitations from
			 * users who are subsequently marked as spam will be invalidated.
			 */
			$hash = wp_hash( "{$invitation->inviter_id}:{$invitation->invitee_email}:{$inviter_ud->user_status}:{$inviter_ud->user_registered}" );
		}
	}

	// If there's a problem, return a string that will change and thus fail.
	if ( ! $hash ) {
		$hash = wp_generate_password( 32, false );
	}

	/**
	 * Filters the hash calculated by the invitation details.
	 *
	 * @since 8.0.0
	 *
	 * @param string $hash Calculated sha1 hash.
	 * @param BP_Invitation object $invitation Invitation hash was created from.
	 */
	return apply_filters( 'bp_members_invitations_get_hash', $hash, $invitation );
}


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.