WC_Helper::_flush_authentication_cache()public staticWC 1.0

Flush auth cache.

Method of the class: WC_Helper{}

No Hooks.

Return

null. Nothing (null).

Usage

$result = WC_Helper::_flush_authentication_cache();

WC_Helper::_flush_authentication_cache() code 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;
}