Notification::list_( $args,  $assoc_args )

Get a list of notifications.


Description Description

Top ↑

OPTIONS OPTIONS

[–=] : One or more parameters to pass.

[–fields=] : Fields to display.

[–user-id=] : Limit results to a specific member. Accepts either a user_login or a numeric ID.

[–component=] : The component to fetch notifications (groups, activity, etc).

[–action=] : Name of the action to fetch notifications. (comment_reply, update_reply, etc).

Top ↑

[–count=] : How many notification items to list. [–count=] : How many notification items to list.

Top ↑

default: 50 default: 50

Top ↑

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

default: table options:

Top ↑

EXAMPLES EXAMPLES

$ wp bp notification list --format=ids
15 25 34 37 198

$ wp bp notification list --format=count
10

$ wp bp notification list --fields=id,user_id
| id     | user_id  |
| 66546  | 656      |
| 54554  | 646546   |

Source Source

File: cli/src/notification.php

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

		$query_args = wp_parse_args(
			$assoc_args,
			array(
				'count' => 50,
			)
		);

		if ( isset( $assoc_args['user-id'] ) ) {
			$user                  = $this->get_user_id_from_identifier( $assoc_args['user-id'] );
			$query_args['user_id'] = $user->ID;
		}

		if ( isset( $assoc_args['action'] ) ) {
			$query_args['component_action'] = $assoc_args['action'];
		}

		if ( isset( $assoc_args['component'] ) ) {
			$query_args['component_name'] = $assoc_args['component'];
		}

		$query_args['per_page'] = $query_args['count'];

		$query_args = self::process_csv_arguments_to_arrays( $query_args );

		$notifications = \BP_Notifications_Notification::get( $query_args );

		if ( empty( $notifications ) ) {
			WP_CLI::error( 'No notification items found.' );
		}

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


Top ↑

User Contributed Notes User Contributed Notes

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