BBP_BuddyPress_Activity::topic_update( int $topic_id, obj $post = null )
Update the activity stream entry when a topic status changes
Description Description
Parameters Parameters
- $topic_id
-
(Required)
- $post
-
(Optional)
Default value: null
Return Return
(Bail) early if not a topic, or topic is by anonymous user
Source Source
File: includes/extend/buddypress/activity.php
public function topic_update( $topic_id = 0, $post = null ) {
// Bail early if not a topic
if ( get_post_type( $post ) !== bbp_get_topic_post_type() ) {
return;
}
// Bail early if revisions are off
if ( ! bbp_allow_revisions() || ! post_type_supports( bbp_get_topic_post_type(), 'revisions' ) ) {
return;
}
$topic_id = bbp_get_topic_id( $topic_id );
// Bail early if topic is by anonymous user
if ( bbp_is_topic_anonymous( $topic_id ) ) {
return;
}
// Action based on new status
if ( bbp_is_topic_public( $post->ID ) ) {
// Validate topic data
$forum_id = bbp_get_topic_forum_id( $topic_id );
$topic_author_id = bbp_get_topic_author_id( $topic_id );
$this->topic_create( $topic_id, $forum_id, array(), $topic_author_id );
} else {
$this->topic_delete( $topic_id );
}
}