Activity_Favorite::create( $args )

Add an activity item as a favorite for a user.


Description Description

Top ↑

OPTIONS OPTIONS

: ID of the activity to add an item to.
: Identifier for the user. Accepts either a user_login or a numeric ID.
## EXAMPLES
$ wp bp activity favorite add 100 500 Success: Activity item added as a favorite for the user.
$ wp bp activity favorite create 100 user_test Success: Activity item added as a favorite for the user.


Source Source

File: cli/src/activity-favorite.php

	public function create( $args ) {
		$activity = bp_activity_get_specific(
			array(
				'activity_ids'     => $args[0],
				'spam'             => null,
				'display_comments' => true,
			)
		);

		$activity = $activity['activities'][0];

		if ( ! is_object( $activity ) ) {
			WP_CLI::error( 'Could not find the activity.' );
		}

		$user = $this->get_user_id_from_identifier( $args[1] );

		if ( bp_activity_add_user_favorite( $activity->id, $user->ID ) ) {
			WP_CLI::success( 'Activity item added as a favorite for the user.' );
		} else {
			WP_CLI::error( 'Could not add the activity item.' );
		}
	}


Top ↑

User Contributed Notes User Contributed Notes

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