WC_Helper::_flush_authentication_cache()public staticWC 1.0

Flush auth cache.

Метод класса: WC_Helper{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$result = WC_Helper::_flush_authentication_cache();

Код WC_Helper::_flush_authentication_cache() WC 8.7.0

public static function _flush_authentication_cache() {
	$request = WC_Helper_API::get(
		'oauth/me',
		array(
			'authenticated' => true,
		)
	);

	if ( wp_remote_retrieve_response_code( $request ) !== 200 ) {
		return false;
	}

	$user_data = json_decode( wp_remote_retrieve_body( $request ), true );
	if ( ! $user_data ) {
		return false;
	}

	WC_Helper_Options::update(
		'auth_user_data',
		array(
			'name'  => $user_data['name'],
			'email' => $user_data['email'],
		)
	);

	return true;
}