Activity_Favorite::list_( $args,  $assoc_args )

Get a user’s favorite activity items.


Description Description

Top ↑

OPTIONS OPTIONS

: Identifier for the user. Accepts either a user_login or a numeric ID.
[–=] : One or more parameters to pass to \BP_Activity_Activity::get()
[–format=] : Render output in a particular format. — default: table options: – table – csv – ids – json – count – yaml —
[–count=] : How many activity favorites to list. — default: 50 —
## EXAMPLES
$ wp bp activity favorite list 315


Source Source

File: cli/src/activity-favorite.php

	public function list_( $args, $assoc_args ) { // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
		$user      = $this->get_user_id_from_identifier( $args[0] );
		$favorites = bp_activity_get_user_favorites( $user->ID );

		if ( empty( $favorites ) ) {
			WP_CLI::error( 'No favorite found for this user.' );
		}

		$activities = bp_activity_get_specific(
			array(
				'activity_ids' => (array) $favorites,
				'per_page'     => $assoc_args['count'],
			)
		);

		// Sanity check.
		if ( empty( $activities['activities'] ) ) {
			WP_CLI::error( 'No favorite found for this user.' );
		}

		$this->get_formatter( $assoc_args )->display_items( $activities['activities'] );
	}


Top ↑

User Contributed Notes User Contributed Notes

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