* : The ID of the user to inspect. * * [--format=] * : Render output in a particular format. * --- * default: table * options: * - table * - json * --- * * ## EXAMPLES * * wp user-id inspect 1 * * @when after_wp_load */ public function inspect( $args, $assoc_args ) { $user_id = (int) $args[0]; $user = get_userdata( $user_id ); if ( ! $user ) { WP_CLI::error( "User not found." ); } $roles = ! empty( $user->roles ) ? implode( ', ', $user->roles ) : 'None'; $caps = ! empty( $user->allcaps ) ? implode( ', ', array_keys( array_filter( $user->allcaps ) ) ) : 'None'; $data = array( array( 'key' => 'ID', 'value' => $user->ID ), array( 'key' => 'Username', 'value' => $user->user_login ), array( 'key' => 'Email', 'value' => $user->user_email ), array( 'key' => 'Roles', 'value' => $roles ), array( 'key' => 'Capabilities', 'value' => $caps ), array( 'key' => 'Registered', 'value' => $user->user_registered ), ); WP_CLI\Utils\format_items( $assoc_args['format'], $data, array( 'key', 'value' ) ); } } WP_CLI::add_command( 'user-id', 'User_ID_CLI_Command' );