Created
December 19, 2023 17:19
-
-
Save verygoodplugins/ecd443e2dcd0f0ad42cc33476da2a653 to your computer and use it in GitHub Desktop.
Store additional customer parameters during an EDD license check
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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