Last active
August 29, 2015 13:56
-
-
Save strangerstudios/9331183 to your computer and use it in GitHub Desktop.
Save the date the TOS was checked at checkout with Paid Memberships Pro
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 field to profile | |
function my_pmprorh_init() | |
{ | |
if(!function_exists("pmprorh_add_registration_field")) | |
return; | |
$secret = new PMProRH_Field("tos_checked_date", "readonly", array("profile"=>"admin", "label"=>"TOS Checked Date")); | |
pmprorh_add_registration_field("checkout_boxes", $secret); | |
} | |
//save after checkout | |
function my_pmpro_after_checkout_tos_save($user_id) | |
{ | |
if(!empty($_REQUEST['tos'])) | |
{ | |
update_user_meta($user_id, "tos_checked_date", date(get_option("date_format"))); | |
update_user_meta($user_id, "tos_checked_ip", get_the_user_ip()); | |
} | |
} | |
add_action('pmpro_after_checkout', 'my_pmpro_after_checkout_tos_save'); | |
//from: http://www.wpbeginner.com/wp-tutorials/how-to-display-a-users-ip-address-in-wordpress/ | |
function get_the_user_ip() { | |
if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { | |
//check ip from share internet | |
$ip = $_SERVER['HTTP_CLIENT_IP']; | |
} elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { | |
//to check ip is pass from proxy | |
$ip = $_SERVER['HTTP_X_FORWARDED_FOR']; | |
} else { | |
$ip = $_SERVER['REMOTE_ADDR']; | |
} | |
return apply_filters( 'wpb_get_ip', $ip ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment