WC_REST_Authentication::authentication_fallback() public WC 1.0
Authenticate the user if authentication wasn't performed during the determine_current_user action.
Necessary in cases where wp_get_current_user() is called before WooCommerce is loaded.
{} Это метод класса: WC_REST_Authentication{}
Хуков нет.
Возвращает
WP_Error/null/true/false.
Использование
$WC_REST_Authentication = new WC_REST_Authentication(); $WC_REST_Authentication->authentication_fallback( $error );
- $error(WP_Error/null/true/false) (обязательный)
- Error data.
Заметки
Код WC_REST_Authentication::authentication_fallback() WC REST Authentication::authentication fallback WC 4.9.0
public function authentication_fallback( $error ) {
if ( ! empty( $error ) ) {
// Another plugin has already declared a failure.
return $error;
}
if ( empty( $this->error ) && empty( $this->auth_method ) && empty( $this->user ) && 0 === get_current_user_id() ) {
// Authentication hasn't occurred during `determine_current_user`, so check auth.
$user_id = $this->authenticate( false );
if ( $user_id ) {
wp_set_current_user( $user_id );
return true;
}
}
return $error;
}