BBP_BuddyPress_Activity::topic_update( $topic_id, obj $post = null )

Update the activity stream entry when a topic status changes

Description

Parameters

$post_id

(int) (Required)

$post

(obj) (Optional)

Default value: null

Return

(Bail) early if not a topic, or topic is by anonymous user

Source

File: bp-forums/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;

		$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 ( in_array( $post->post_status, array( bbp_get_public_status_id(), bbp_get_closed_status_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 );
		}
	}

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.