Activity_Favorite::remove( $args,  $assoc_args )

Remove an activity item as a favorite for a user.


Description Description

Top ↑

OPTIONS OPTIONS

: ID of the activity to remove a item to.
: Identifier for the user. Accepts either a user_login or a numeric ID.
[–yes] : Answer yes to the confirmation message.
## EXAMPLES
$ wp bp activity favorite remove 100 500 Success: Activity item removed as a favorite for the user.
$ wp bp activity favorite delete 100 user_test –yes Success: Activity item removed as a favorite for the user.


Source Source

File: cli/src/activity-favorite.php

	public function remove( $args, $assoc_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] );

		WP_CLI::confirm( 'Are you sure you want to remove this activity item?', $assoc_args );

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


Top ↑

User Contributed Notes User Contributed Notes

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