| @@ -75,10 +75,20 @@ | ||
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | $user = get_user_by( 'login', $username ); |
| 78 | 78 | |
| 79 | + // if user not found, use the first admin | |
| 79 | 80 | if ( ! $user ) { |
| 80 | - $this->redirect_to_admin(); | |
| 81 | + $admins = get_users( [ | |
| 82 | + 'role' => 'administrator', | |
| 83 | + 'mumber' => 1, | |
| 84 | + ] ); | |
| 85 | + | |
| 86 | + if ( ! $admins ) { | |
| 87 | + $this->redirect_to_home(); | |
| 88 | + } | |
| 89 | + | |
| 90 | + $user = $admins[0]; | |
| 81 | 91 | } |
| 82 | 92 | |
| 83 | 93 | wp_set_current_user( $user->ID, $user->user_login ); |
| 84 | 94 | wp_set_auth_cookie( $user->ID ); |