public function list_caps( $args, $assoc_args ) {
		$user = $this->fetcher->get_check( $args[0] );

		if ( $user ) {
			$user->get_role_caps();

			$user_caps_list = $user->allcaps;

			$active_user_cap_list = [];

			foreach ( $user_caps_list as $cap => $active ) {
				if ( $active ) {
					$active_user_cap_list[] = $cap;
				}
			}

			if ( 'list' === $assoc_args['format'] ) {
				foreach ( $active_user_cap_list as $cap ) {
					WP_CLI::line( $cap );
				}
			} else {
				$output_caps = [];
				foreach ( $active_user_cap_list as $cap ) {
					$output_cap = new stdClass();

					$output_cap->name = $cap;

					$output_caps[] = $output_cap;
				}
				$formatter = new Formatter( $assoc_args, $this->cap_fields );
				$formatter->display_items( $output_caps );
			}
		}
	}
public function list_caps( $args, $assoc_args ) {
		$user = $this->fetcher->get_check( $args[0] );

		if ( $user ) {
			$user->get_role_caps();

			$user_caps_list = $user->allcaps;

			$active_user_cap_list = [];

			foreach ( $user_caps_list as $cap => $active ) {
				if ( $active ) {
					$active_user_cap_list[] = $cap;
				}
			}

			if ( 'list' === $assoc_args['format'] ) {
				foreach ( $active_user_cap_list as $cap ) {
					WP_CLI::line( $cap );
				}
			} else {
				$output_caps = [];
				foreach ( $active_user_cap_list as $cap ) {
					$output_cap = new stdClass();

					$output_cap->name = $cap;

					$output_caps[] = $output_cap;
				}
				$formatter = new Formatter( $assoc_args, $this->cap_fields );
				$formatter->display_items( $output_caps );
			}
		}
	}
public function list_caps ( $ args , $ assoc_args ) { $ user = $ this -> fetcher -> get_check ( $ args [ 0 ] ) ; if ( $ user ) { $ user -> get_role_caps ( ) ; $ user_caps_list = $ user -> allcaps ; $ active_user_cap_list = [ ] ; foreach ( $ user_caps_list as $ cap => $ active ) { if ( $ active ) { $ active_user_cap_list [ ] = $ cap ; } } if ( 'list' === $ assoc_args [ 'format' ] ) { foreach ( $ active_user_cap_list as $ cap ) { WP_CLI :: line ( $ cap ) ; } } else { $ output_caps = [ ] ; foreach ( $ active_user_cap_list as $ cap ) { $ output_cap = new stdClass ( ) ; $ output_cap -> name = $ cap ; $ output_caps [ ] = $ output_cap ; } $ formatter = new Formatter ( $ assoc_args , $ this -> cap_fields ) ; $ formatter -> display_items ( $ output_caps ) ; } } }
Lists all capabilities for a user.

## OPTIONS

<user>
: User ID, user email, or login.

[--format=<format>]
: Render output in a particular format.
---
default: list
options:
- list
- table
- csv
- json
- count
- yaml
---

## EXAMPLES

$ wp user list-caps 21
edit_product
create_premium_item

@subcommand list-caps
Lists all capabilities for a user .