| @@ -173,18 +173,27 @@ | ||
| 173 | 173 | if( ! empty( $endpoint ) ) { |
| 174 | 174 | $_additional_data['endpoint'] = $endpoint; |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - // Delete user logged meta data | |
| 178 | - $this->utils('options') | |
| 179 | - ->remove('user') | |
| 180 | - ->remove('favourites') | |
| 181 | - ->remove('reviews') | |
| 182 | - ->remove('cloud_activity') | |
| 183 | - ->remove('api_key'); | |
| 177 | + // Delete user logged meta data — pinned to the acting user, otherwise | |
| 178 | + // Options::user_id() resolves a linked user to the global-login | |
| 179 | + // administrator and clears the administrator's session instead. | |
| 180 | + $options = $this->utils('options'); | |
| 181 | + $options->use_current_user( true ); | |
| 184 | 182 | |
| 185 | - if( $this->utils('options')->who_am_i() === 'global' ) { | |
| 186 | - $this->utils('options')->remove_global_login(); | |
| 183 | + try { | |
| 184 | + $options | |
| 185 | + ->remove('user') | |
| 186 | + ->remove('favourites') | |
| 187 | + ->remove('reviews') | |
| 188 | + ->remove('cloud_activity') | |
| 189 | + ->remove('api_key'); | |
| 190 | + | |
| 191 | + if( $options->who_am_i() === 'global' ) { | |
| 192 | + $options->remove_global_login(); | |
| 193 | + } | |
| 194 | + } finally { | |
| 195 | + $options->use_current_user( false ); | |
| 187 | 196 | } |
| 188 | 197 | |
| 189 | 198 | return new WP_Error( 'invalid_api_key', $message, $_additional_data ); |
| 190 | 199 | } |