Messages::star_thread( $args,  $assoc_args )

Star a thread.


Description Description

Top ↑

OPTIONS OPTIONS

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


Source Source

File: cli/src/messages.php

	public function star_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'    => 'star',
			'thread_id' => $thread_id,
			'user_id'   => $user->ID,
			'bulk'      => true,
		);

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


Top ↑

User Contributed Notes User Contributed Notes

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