bbp_update_topic_engagements( int $topic_id )
Update the engagements of a topic.
Description Description
Hooked to ‘bbp_new_topic’ and ‘bbp_new_reply’, this gets the post author and if not anonymous, passes it into bbp_add_user_engagement().
Parameters Parameters
- $topic_id
-
(Required)
Source Source
File: includes/users/engagements.php
function bbp_update_topic_engagements( $topic_id = 0 ) { // Is a reply if ( bbp_is_reply( $topic_id ) ) { // Bail if reply isn't published if ( ! bbp_is_reply_published( $topic_id ) ) { return; } $author_id = bbp_get_reply_author_id( $topic_id ); $topic_id = bbp_get_reply_topic_id( $topic_id ); // Is a topic } elseif ( bbp_is_topic( $topic_id ) ) { // Bail if topic isn't published if ( ! bbp_is_topic_published( $topic_id ) ) { return; } $author_id = bbp_get_topic_author_id( $topic_id ); $topic_id = bbp_get_topic_id( $topic_id ); // Is unknown } else { return; } // Bail if topic is not public if ( ! bbp_is_topic_public( $topic_id ) ) { return; } // Return whether engagement was added return bbp_add_user_engagement( $author_id, $topic_id ); }
Changelog Changelog
Version | Description |
---|---|
2.6.0 | Introduced. |