if ($worked) { //send email to member $pmproemail = new PMProEmail(); $pmproemail->sendBillingEmail($current_user, $morder); //send email to admin $pmproemail = new PMProEmail(); $pmproemail->sendBillingAdminEmail($current_user, $morder); } } else { $worked = true; } if ($worked) { //update the user meta too $meta_keys = array("pmpro_bfirstname", "pmpro_blastname", "pmpro_baddress1", "pmpro_baddress2", "pmpro_bcity", "pmpro_bstate", "pmpro_bzipcode", "pmpro_bphone", "pmpro_bemail", "pmpro_CardType", "pmpro_AccountNumber", "pmpro_ExpirationMonth", "pmpro_ExpirationYear"); $meta_values = array($bfirstname, $blastname, $baddress1, $baddress2, $bcity, $bstate, $bzipcode, $bphone, $bemail, $CardType, hideCardNumber($AccountNumber), $ExpirationMonth, $ExpirationYear); pmpro_replaceUserMeta($current_user->ID, $meta_keys, $meta_values); //message $pmpro_msg = sprintf(__('Information updated. <a href="%s">« back to my account</a>', 'pmpro'), pmpro_url("account")); $pmpro_msgt = "pmpro_success"; } else { $pmpro_msg = $morder->error; if (!$pmpro_msg) { $pmpro_msg = __("Error updating billing information.", 'pmpro'); } $pmpro_msgt = "pmpro_error"; } } } else { //default values from DB $bfirstname = get_user_meta($current_user->ID, "pmpro_bfirstname", true); $blastname = get_user_meta($current_user->ID, "pmpro_blastname", true);
} //in case the user just signed up pmpro_set_current_user(); //add discount code use if ($discount_code && $use_discount_code) { if (!empty($morder->id)) { $code_order_id = $morder->id; } else { $code_order_id = ""; } $wpdb->query("INSERT INTO {$wpdb->pmpro_discount_codes_uses} (code_id, user_id, order_id, timestamp) VALUES('" . $discount_code_id . "', '" . $user_id . "', '" . intval($code_order_id) . "', '" . current_time("mysql") . "')"); } //save billing info ect, as user meta $meta_keys = array("pmpro_bfirstname", "pmpro_blastname", "pmpro_baddress1", "pmpro_baddress2", "pmpro_bcity", "pmpro_bstate", "pmpro_bzipcode", "pmpro_bcountry", "pmpro_bphone", "pmpro_bemail", "pmpro_CardType", "pmpro_AccountNumber", "pmpro_ExpirationMonth", "pmpro_ExpirationYear"); $meta_values = array($bfirstname, $blastname, $baddress1, $baddress2, $bcity, $bstate, $bzipcode, $bcountry, $bphone, $bemail, $CardType, hideCardNumber($AccountNumber), $ExpirationMonth, $ExpirationYear); pmpro_replaceUserMeta($user_id, $meta_keys, $meta_values); //save first and last name fields if (!empty($bfirstname)) { $old_firstname = get_user_meta($user_id, "first_name", true); if (empty($old_firstname)) { update_user_meta($user_id, "first_name", $bfirstname); } } if (!empty($blastname)) { $old_lastname = get_user_meta($user_id, "last_name", true); if (empty($old_lastname)) { update_user_meta($user_id, "last_name", $blastname); } } //show the confirmation $ordersaved = true;