Messages::unstar_thread( $args,  $assoc_args )

Unstar a thread.


Description Description

Top ↑

OPTIONS OPTIONS

: Thread ID to unstar.
–user-id= : User that is unstarring the thread. Accepts either a user_login or a numeric ID.
## EXAMPLE
$ wp bp message unstar-thread 212 –user-id=another_user_login Success: Thread was successfully unstarred.


Source Source

File: cli/src/messages.php

	public function unstar_thread( $args, $assoc_args ) {
		$user      = $this->get_user_id_from_identifier( $assoc_args['user-id'] );
		$thread_id = (int) $args[0];

		// Check if it is a valid thread.
		if ( ! messages_is_valid_thread( $thread_id ) ) {
			WP_CLI::error( 'This is not a valid thread ID.' );
		}

		// Check if the user has access to this thread.
		$id = messages_check_thread_access( $thread_id, $user->ID );
		if ( ! is_numeric( $id ) ) {
			WP_CLI::error( 'User has no access to this thread.' );
		}

		$star_args = array(
			'action'    => 'unstar',
			'thread_id' => $thread_id,
			'user_id'   => $user->ID,
			'bulk'      => true,
		);

		if ( bp_messages_star_set_action( $star_args ) ) {
			WP_CLI::success( 'Thread was successfully unstarred.' );
		} else {
			WP_CLI::error( 'Something wrong while trying to unstar the thread.' );
		}
	}


Top ↑

User Contributed Notes User Contributed Notes

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