/*$blogname = get_option('blogname');
$tran_success = false;
//getting purchase post title and & price - issue #981
$post_obj = mgm_get_post($post_id);
$purchase_cost = mgm_convert_to_currency($post_obj->purchase_cost);
$post = get_post($post_id);
$post_title = $post->post_title; */
/*//issue #504
if($user_id){
// subject
$subject = $system_obj->get_template('payment_success_email_template_subject', array('blogname'=>$blogname), true);
// body
$message = $system_obj->get_template('payment_success_email_template_body',
array('blogname'=>$blogname, 'name'=>$user->display_name,
'post_title'=>$post_title,'purchase_cost'=>$purchase_cost,
'email'=>$user->user_email,
'admin_email'=>$system_obj->setting['admin_email']), true);
}*/
//issue #504
if($user_id){
// subject
$subject = $system_obj->get_template('payment_failed_email_template_subject', array('blogname'=>$blogname), true);
// body
$message = $system_obj->get_template('payment_failed_email_template_body',
array('blogname'=>$blogname, 'name'=>$user->display_name,
'post_title'=>$post_title,'purchase_cost'=>$purchase_cost,
'email'=>$user->user_email, 'payment_type'=>'post purchase payment','reason'=>$status_str,
'admin_email'=>$system_obj->setting['admin_email']), true);
}
//issue #504
if($user_id){
// subject
$subject = $system_obj->get_template('payment_pending_email_template_subject', array('blogname'=>$blogname), true);
// body
$message = $system_obj->get_template('payment_pending_email_template_body',
array('blogname'=>$blogname, 'name'=>$user->display_name,
'post_title'=>$post_title,'purchase_cost'=>$purchase_cost,
'email'=>$user->user_email, 'reason'=>$status_str,
'admin_email'=>$system_obj->setting['admin_email']), true);
}
//issue #504
if($user_id){
// subject
$subject = $system_obj->get_template('payment_unknown_email_template_subject', array('blogname'=>$blogname), true);
// body
$message = $system_obj->get_template('payment_unknown_email_template_body',
array('blogname'=>$blogname, 'name'=>$user->display_name,
'post_title'=>$post_title,'purchase_cost'=>$purchase_cost,
'email'=>$user->user_email, 'reason'=>$status_str,
'admin_email'=>$system_obj->setting['admin_email']), true);
}
// notify user
if(!$dpne) {
if($user_id && $this->is_payment_email_sent($_POST['M_custom'])) {
//issue #862
$subject = mgm_replace_email_tags($subject,$user_id);
$message = mgm_replace_email_tags($message,$user_id);
mgm_mail($user->user_email, $subject, $message); //send an email to the buyer
//update as email sent
$this->record_payment_email_sent($_POST['M_custom']);
}
}
$status = __('Failed join', 'mgm'); //overridden on a successful payment
if ($tran_success) {
//issue #1421
if($user_id){
do_action('mgm_update_coupon_usage', array('user_id' => $user_id));
}
// mark as purchased
if(isset($guest_token)){
// issue #1421
if(isset($coupon_id) && isset($coupon_code)) {
do_action('mgm_update_coupon_usage', array('guest_token' => $guest_token,'coupon_id' => $coupon_id));
$this->_set_purchased(NULL, $post_id, $guest_token, $_POST['M_custom'],$coupon_code);
}else {
$this->_set_purchased(NULL, $post_id, $guest_token, $_POST['M_custom']);
}
}else{
$this->_set_purchased($user_id, $post_id, NULL, $_POST['M_custom']);
}
// status
$status = __('The post was purchased successfully', 'mgm');
}
// notify admin, only if gateway emails on
if (!$dge) {
// not for guest
if($user_id){
$subject = "[" . $blogname . "] Admin Notification: " . $user->user_email . " purchased post " . $post_id;
$message = "User display name: {$user->display_name}
User email: {$user->user_email}
User ID: {$user->ID}
Status: " . $status . "
Action: Purchase post:" . $subject . "
" . $message . "
" . print_r($_POST, true) . ''; }else{ $subject = "[" . $blogname . "] Admin Notification: Guest[IP: ".mgm_get_client_ip_address()."] purchased post " . $post_id; $message = "Guest Purchase"; } mgm_mail($system_obj->setting['admin_email'], $subject, $message); } if(!$dge){ $message = 'Could not read membership type in the following POST data. Please debug or contact magic members to fix the problem making sure to pass on the following data.
' . "\n\n" . print_r($_POST, true) . ''; mgm_mail($system_obj->setting['admin_email'], 'Error in WorldPay membership verification', $message); } // on status switch ($member->status) { case MGM_STATUS_ACTIVE: //Sending notification email to user - issue #1468 if($notify_user && $is_registration =='Y'){ $user_pass = mgm_decrypt_password($member->user_password, $user_id); do_action('mgm_register_user_notification', $user_id, $user_pass); } //sending upgrade notifaction email to admin if(isset($subscription_option) && $subscription_option =='upgrade'){ do_action('mgm_user_upgrade_notification', $user_id); } // init $subscription = ''; // add trial if ($subs_pack['trial_on']) { // trial $subscription = sprintf('%1$s %2$s for the first %3$s %4$s,
" . print_r($_POST, true) . ''; mgm_mail($system_obj->setting['admin_email'], $subject, $message); } // subject $subject = $system_obj->get_template('subscription_cancelled_email_template_subject', array('blogname'=>$blogname), true); // body $message = $system_obj->get_template('subscription_cancelled_email_template_body', array('blogname'=>$blogname, 'name'=>$user->display_name, 'email'=>$user->user_email, 'admin_email'=>$system_obj->setting['admin_email']), true); // send email notification to user if(!$dpne) { //issue #862 $subject = mgm_replace_email_tags($subject,$user_id); $message = mgm_replace_email_tags($message,$user_id); // mail mgm_mail($user->user_email, $subject, $message); } // send email notification to system administrator if (!$dge) { $subject = "[$blogname] {$user->user_email} - {$new_status}"; $message = " User display name: {$user->display_name}\n\n
" . print_r($_POST, true) . ''; mgm_mail($system_obj->setting['admin_email'], $subject, $message); } $user = get_userdata($user_id); //send notification email to admin: $message = (__('The User: ', 'mgm')). $user->user_email.' ('. $user_id .') '.(__('has upgraded/cancelled subscription.', 'mgm')); $message .= "