芝麻web文件管理V1.00
编辑当前文件:/home/sditechnicalteam/ppclaunchers.com/wp-content/plugins/sg-security/core/Cli/Cli_2fa.php
* : Action name. * default: reset * options: * - reset * *
* : User ID or username. * options: * - id * - username * - all * --- * [
] * : The user ID or username. * * ## EXAMPLES * * wp sg 2fa reset id 1 */ public function __invoke( $args ) { // Bail if no action is provided. if ( ! isset( $args[0] ) ) { return \WP_CLI::error( 'Please provide an action - reset and the user ID/username/all. Per example "wp sg 2fa reset id 1". This will reset the 2fa setup for user with ID 1.' ); } // Initiate the reset action. if ( 'reset' === $args[0] ) { return $this->reset( $args ); } \WP_CLI::error( 'Incorrect setting, please user reset as an option and user ID/Username as a value!' ); } /** * Reset user 2FA. * * @since 1.1.1 */ public function reset( $args ) { // Reset all users 2FA setup if all is selected. if ( 'all' === $args[1] ) { Sg_2fa::get_instance()->reset_all_users_2fa(); // Return success message. return \WP_CLI::success( '2FA successfully reset for all users!' ); } if ( empty( $args[2] ) ) { // Return error message if there is no such user. \WP_CLI::error( 'You need to define user ID or username.' ); } // Get the user. $user = ( 'id' === $args[1] ) ? get_user_by( 'ID', $args[2] ) : get_user_by( 'login', $args[2] ); if ( false === $user ) { // Return error message if there is no such user. \WP_CLI::error( 'User with such ' . $args[1] . ' does not exist!' ); } // Reset the 2FA for the user. if ( Sg_2fa::get_instance()->reset_user_2fa( $user->ID ) ) { // Return success message. \WP_CLI::success( '2FA successfully reset for ' . $args[1] . ' ' . $args[2] . '!' ); } else { // Return error message. \WP_CLI::error( 'Incorrect ' . $args[1] . '!' ); } } }