Last active
August 29, 2015 14:04
-
-
Save generatepress/cc029815b4da21db3292 to your computer and use it in GitHub Desktop.
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
add_action('admin_init', 'generate_activate_customer_email'); | |
function generate_activate_customer_email() { | |
if( isset( $_POST['generate_customer_email_activate'] ) ) { | |
if( ! check_admin_referer( 'generate_customer_email_nonce', 'generate_customer_email_nonce' ) ) | |
return; // get out if we didn't click the Activate button | |
$generate_customer_email = get_option( 'generate_customer_email' ); | |
global $wp_version; | |
$response = wp_remote_post( | |
'http://myurl.com/api/licenses/check-email.php', | |
array( | |
'body' => | |
array( | |
'email' => $generate_customer_email, | |
) | |
) | |
); | |
// make sure the response came back okay | |
if ( is_wp_error( $response ) ) | |
return false; | |
$downloads = json_decode(wp_remote_retrieve_body( $response ), true); | |
$generate_member_info = array(); | |
if ( !empty( $downloads ) ) : | |
update_option( 'generate_purchased_products', $downloads ); | |
update_option( 'generate_customer_email_status', 'valid' ); | |
else : | |
update_option( 'generate_purchased_products', '' ); | |
update_option( 'generate_customer_email_status', 'false' ); | |
endif; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment