Messages::unstar( $args,  $assoc_args )

Unstar a message.


Description Description

Top ↑

OPTIONS OPTIONS

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


Source Source

File: cli/src/messages.php

	public function unstar( $args, $assoc_args ) {
		$user    = $this->get_user_id_from_identifier( $assoc_args['user-id'] );
		$user_id = $user->ID;
		$msg_id  = (int) $args[0];

		// Check if the message is starred first.
		if ( ! bp_messages_is_message_starred( $msg_id, $user_id ) ) {
			WP_CLI::error( 'You need to star a message first before unstarring it.' );
		}

		$star_args = array(
			'action'     => 'unstar',
			'message_id' => $msg_id,
			'user_id'    => $user_id,
		);

		if ( bp_messages_star_set_action( $star_args ) ) {
			WP_CLI::success( 'Message was successfully unstarred.' );
		} else {
			WP_CLI::error( 'Message was not unstarred.' );
		}
	}


Top ↑

User Contributed Notes User Contributed Notes

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