bbp_add_user_subscription( int $user_id, int $object_id, string $type = 'post' )

Add a user subscription


Description Description


Parameters Parameters

$user_id

(Optional) User id

$object_id

(Optional) Object id

$type

(Optional) Type of object being subscribed to

Default value: 'post'


Top ↑

Return Return

(bool) True if the object was added to user subscriptions, otherwise false


Top ↑

Source Source

File: includes/users/engagements.php

function bbp_add_user_subscription( $user_id = 0, $object_id = 0, $type = 'post' ) {

	// Bail if not enough info
	if ( empty( $user_id ) || empty( $object_id ) ) {
		return false;
	}

	// Bail if already subscribed
	if ( bbp_is_user_subscribed( $user_id, $object_id, $type ) ) {
		return false;
	}

	// Bail if add fails
	if ( ! bbp_add_user_to_object( $object_id, $user_id, '_bbp_subscription', $type ) ) {
		return false;
	}

	do_action( 'bbp_add_user_subscription', $user_id, $object_id, $type );

	return true;
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.6.0 bbPress (r6544) Added $type parameter
2.5.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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