WC_REST_Authentication::update_last_access()privateWC 1.0

Updated API Key last access datetime.

Method of the class: WC_REST_Authentication{}

Return

null. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->update_last_access();

WC_REST_Authentication::update_last_access() code WC 8.7.0

private function update_last_access() {
	global $wpdb;

	/**
	 * This filter enables the exclusion of the most recent access time from being logged for REST API calls.
	 *
	 * @param bool $result  Default value.
	 * @param int  $key_id  Key ID associated with REST API request.
	 * @param int  $user_id User ID associated with REST API request.
	 *
	 * @since 7.7.0
	 */
	if ( apply_filters( 'woocommerce_disable_rest_api_access_log', false, $this->user->key_id, $this->user->user_id ) ) {
		return;
	}

	$wpdb->update(
		$wpdb->prefix . 'woocommerce_api_keys',
		array( 'last_access' => current_time( 'mysql' ) ),
		array( 'key_id' => $this->user->key_id ),
		array( '%s' ),
		array( '%d' )
	);
}