Exemplo n.º 1
0
 protected function validate_settings()
 {
     if (!$this->can_save()) {
         return;
     }
     if (empty($this->settings['new_username']) || 'admin' === $this->settings['new_username']) {
         $this->settings['new_username'] = null;
     }
     if (is_null($this->settings['new_username']) && false === $this->settings['change_id']) {
         return;
     }
     $result = $this->change_admin_user($this->settings['new_username'], $this->settings['change_id']);
     if ($result) {
         $this->add_message(__('The user was successfully updated.', 'better-wp-security'));
         ITSEC_Response::set_show_default_success_message(false);
         ITSEC_Response::force_logout();
     } else {
         $this->set_can_save(false);
         $this->add_error(new WP_Error('itsec-admin-user-failed-change-admin-user', __('The user was unable to be successfully updated. This could be due to a plugin or server configuration conflict.', 'better-wp-security')));
         ITSEC_Response::set_show_default_error_message(false);
     }
 }