Skip to content

Instantly share code, notes, and snippets.

@verygoodplugins
Created December 19, 2023 17:19
Show Gist options
  • Save verygoodplugins/ecd443e2dcd0f0ad42cc33476da2a653 to your computer and use it in GitHub Desktop.
Save verygoodplugins/ecd443e2dcd0f0ad42cc33476da2a653 to your computer and use it in GitHub Desktop.
Store additional customer parameters during an EDD license check
<?php
function store_additional_license_parameters( $response, $args, $license_id ) {
$data = array_map( 'sanitize_text_field', $_REQUEST );
if ( $response['license'] == 'valid' ) {
$user = get_user_by( 'email', $response['customer_email'] );
if ( ! $user ) {
return $response;
}
update_user_meta( $user->ID, 'last_license_check', date( 'm/d/Y' ) );
if ( isset( $data['version'] ) ) {
update_user_meta( $user->ID, 'wpf_version', $data['version'] );
}
}
return $response;
}
add_filter( 'edd_remote_license_check_response', 'store_additional_license_parameters', 10, 3 );
add_filter( 'edd_remote_license_activation_response', 'store_additional_license_parameters', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment