Messages::list_( $args,  $assoc_args )

Get a list of messages for a specific user.


Description Description

Top ↑

OPTIONS OPTIONS

–user-id= : Identifier for the user. Accepts either a user_login or a numeric ID.

[–=] : One or more parameters to pass. See \BP_Messages_Box_Template()

[–fields=] : Fields to display.

Top ↑

[–count=] : How many messages to list. [–count=] : How many messages to list.

Top ↑

default: 10 default: 10

Top ↑

[–box=] : Box of the message. [–box=] : Box of the message.

default: sentbox options:

Top ↑

[–type=] : Type of the message. [–type=] : Type of the message.

default: all options:

Top ↑

[–format=] : Render output in a particular format. [–format=] : Render output in a particular format.

default: table options:

Top ↑

EXAMPLES EXAMPLES

$ wp bp message list --user-id=544 --format=count
10

$ wp bp message list --user-id=user_login --count=3 --format=ids
5454 45454 4545 465465

Source Source

File: cli/src/messages.php

	public function list_( $args, $assoc_args ) { // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
		$formatter = $this->get_formatter( $assoc_args );

		$r = wp_parse_args(
			$assoc_args,
			array(
				'search' => '',
			)
		);

		$user = $this->get_user_id_from_identifier( $assoc_args['user-id'] );

		$inbox = new \BP_Messages_Box_Template(
			array(
				'user_id'      => $user->ID,
				'box'          => $r['box'],
				'type'         => $r['type'],
				'max'          => $r['count'],
				'search_terms' => $r['search'],
			)
		);

		if ( ! $inbox->has_threads() ) {
			WP_CLI::error( 'No messages found.' );
		}

		$messages = $inbox->threads[0]->messages;

		if ( 'ids' === $formatter->format ) {
			echo implode( ' ', wp_list_pluck( $messages, 'id' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
		} else {
			$formatter->display_items( $messages );
		}
	}


Top ↑

User Contributed Notes User Contributed Notes

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