Automatic emails
-
Hello.
We have a crowdfunding website. when someone back a project, the author and the backer must receive an automated email.
Its few days that this function suddenly is not working!!!
Here is the code in the function.php of the crowdfunding theme:// Email the funder and the author
$author = get_userdata($project->post_author);
$rewards = get_children(array(
‘post_parent’ => $project->ID,
‘post_type’ => ‘reward’,
‘order’ => ‘ASC’,
‘orderby’ => ‘meta_value_num’,
‘meta_key’ => ‘funding_amount’,
));
$funders = array();
$funded_amount = 0;
$chosen_reward = null;
foreach($rewards as $this_reward){
$these_funders = get_children(array(
‘post_parent’ => $this_reward->ID,
‘post_type’ => ‘funder’,
‘post_status’ => ‘publish’
));
foreach($these_funders as $this_funder){
$funding_amount = get_post_meta($this_funder->ID, ‘funding_amount’, true);
$funders[] = $this_funder;
$funded_amount += $funding_amount;
}
}
$site = site_url();
$funder_details = get_post_meta($funder->ID, ‘funder’, true);
$funding_amount = get_post_meta($funder->ID, ‘funding_amount’, true);
$preapproval_key = get_post_meta($funder->ID, ‘preapproval_key’,true);
// Send an email to the post authorif(get_option(‘date_format’) == ‘m/d/Y’ && strtotime($project_settings[‘date’]) != false){
$array = explode(‘/’, $project_settings[‘date’]);
$tmp = $array[0];
$array[0] = $array[1];
$array[1] = $tmp;
unset($tmp);
$project_settings[‘date’] = implode(‘/’, $array);
}if(get_option(‘date_format’) == ‘d/m/Y’ && strtotime($project_settings[‘date’]) != false){
$array = explode(‘/’, $project_settings[‘date’]);
$tmp = $array[0];
$array[0] = $array[1];
$array[1] = $tmp;
unset($tmp);
$project_settings[‘date’] = implode(‘/’, $array);
}if (strpos( $project_settings[‘date’] , ‘/’) !== false) {
$parseddate = str_replace(‘/’ , ‘.’ , $project_settings[‘date’]);
}else{
$parseddate = $project_settings[‘date’];
}
$project_expired = strtotime($parseddate) < time();if(strpos(F_Controller::timesince(time(), strtotime($parseddate), 1, ”), ‘hour’)){
$timing = __(‘< 24’, ‘funding’);
}else{
$timing = F_Controller::timesince(time(), strtotime($parseddate), 1, ”);
}if(strpos(F_Controller::timesince(time(), strtotime($parseddate), 1, ”), ‘hour’)){
$timingtext = __(‘hours to go’, ‘funding’);
}else{if(F_Controller::timesince(time(), strtotime($parseddate), 1, ”) == 1){
$timingtext = __(‘day to go’, ‘funding’);
}else{
$timingtext = __(‘days to go’, ‘funding’);
}
}$to_author = of_get_option(‘f2a’);
$to_author = wordwrap(sprintf(
$to_author,
$author->user_nicename, // $author->display_name
ucfirst($funder_details[‘name’]),
$project->post_title,
$project_currency_sign.$funded_amount,
round($funded_amount/$project_settings[‘target’]*100),
$project_currency_sign.$project_settings[‘target’],
$timing. ‘ ‘. $timingtext,
$funder->ID,
$funder_details[‘name’],
$funder_details[’email’],
$project_currency_sign.$funding_amount,
$preapproval_key,
$reward->post_title,
$funder->post_content
), 75);
$headers = array(‘Content-Type: text/html; charset=UTF-8’, ‘From: ”.$site->site_name.” <funding@’.$site->domain.’>’.’rn’);
@wp_mail(
$author->user_email,
sprintf(__(‘New Funder For %s’, ‘funding’), $project->post_title),
$to_author,
$headers
);
// Send an email to the funder
$funder_paypal_email = get_post_meta($funder->ID, ‘paypal_email’, true);
$to_funder = of_get_option(‘f2f’);
$to_funder = wordwrap(sprintf(
$to_funder,
$funder_details[‘name’],
$project->post_title,
round($funded_amount/$project_settings[‘target’]*100),
$project_currency_sign.$project_settings[‘target’],
$timing. ‘ ‘ .$timingtext,
$funder->ID,
$funder_details[‘name’],
$funder_details[’email’],
$funding_amount,
$preapproval_key,
$reward->post_title,
$funder->post_content,
get_permalink($project->ID),
get_bloginfo(‘name’),
site_url()
),75);
$headers = array(‘Content-Type: text/html; charset=UTF-8’, ‘From: ”.$site->site_name.” <funding@’.$site->domain.’>’.’rn’);
@wp_mail(
$funder_paypal_email,
sprintf(__(‘Thanks For Funding %s’, ‘funding’), $project->post_title),
$to_funder,
$headers
);
update_post_meta($funder->ID, ‘notified’, true);
}
wp_publish_post( $theid );
$url = add_query_arg(‘thanks’, 1, get_post_permalink($project->ID));
header(‘Location: ‘.$url, true, 303);}
}
}Please help us finding a solution!!!!
Thanks -
Hi @babimc,
Unfortunately, this isn’t the right WordPress forum to help with that problem. You appear to have a self-hosted site using the WordPress.org software, but this forum is for blogs hosted here on WordPress.com.
The two versions are different and have separate forums. Please post your question at the WordPress.org forum: https://wordpress.org/support/
If you don’t have a username at that forum, you’ll need to register before posting.For more information about the differences between WordPress.com and WordPress.org, visit: http://en.support.wordpress.com/com-vs-org/.
Cheers! -
- The topic ‘Automatic emails’ is closed to new replies.