Group_Member::remove( $args,  $assoc_args )

Remove a member from a group.


Description Description

Top ↑

OPTIONS OPTIONS

–group-id= : Identifier for the group. Accepts either a slug or a numeric ID.

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

Top ↑

EXAMPLES EXAMPLES

$ wp bp group member remove --group-id=3 --user-id=10
Success: Member #10 removed from the group #3.

$ wp bp group member delete --group-id=foo --user-id=admin
Success: Member #545 removed from the group #12.

Source Source

File: cli/src/group-member.php

	public function remove( $args, $assoc_args ) {
		$group_id = $this->get_group_id_from_identifier( $assoc_args['group-id'] );
		$user     = $this->get_user_id_from_identifier( $assoc_args['user-id'] );
		$member   = new \BP_Groups_Member( $user->ID, $group_id );

		// True on success.
		if ( $member->remove() ) {
			WP_CLI::success( sprintf( 'Member #%d removed from the group #%d.', $user->ID, $group_id ) );
		} else {
			WP_CLI::error( 'Could not remove member from the group.' );
		}
	}


Top ↑

User Contributed Notes User Contributed Notes

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