bbp_add_user_engagement( int $user_id, int $topic_id )

Add a topic to user’s engagements


Description Description

Note that both the User and Topic should be verified to exist before using this function. Originally both were validated, but because this function is frequently used within a loop, those verifications were moved upstream to improve performance on topics with many engaged users.


Parameters Parameters

$user_id

(Optional) User id

$topic_id

(Optional) Topic id


Top ↑

Return Return

(bool) Always true


Top ↑

Source Source

File: includes/users/engagements.php

function bbp_add_user_engagement( $user_id = 0, $topic_id = 0 ) {

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

	// Bail if already a engaged
	if ( bbp_is_user_engaged( $user_id, $topic_id ) ) {
		return false;
	}

	// Bail if add fails
	if ( ! bbp_add_user_to_object( $topic_id, $user_id, '_bbp_engagement' ) ) {
		return false;
	}

	do_action( 'bbp_add_user_engagement', $user_id, $topic_id );

	return true;
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.6.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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