【发布时间】:2017-02-02 07:26:27
【问题描述】:
我创建了一个插件,可以在用户使用贝宝捐款后向他们发送电子邮件。但问题是用户没有收到任何电子邮件。请在下面检查我的代码。我也在使用名为“PayPal IPN for WordPress”的插件来获取捐赠信息。
<?php
/*
Plugin Name: PayPal IPN Send Email
Plugin URI: http://www.trustedwebsolution.com/
Description: Hook tester for PayPal IPN for WordPress plugin.
Author: Jhishu Singha
Version: 1.0.0
*/
add_action('paypal_ipn_for_wordpress_payment_status_processed', 'paypal_ipn_for_wordpress_payment_email', 10, 1);
function paypal_ipn_for_wordpress_payment_email($posted) {
// Parse data from IPN $posted array
$dir = plugin_dir_url( __FILE__ );
$item_name = isset($posted['item_name']) ? $posted['item_name'] : '';
$payment_gross = isset($posted['payment_gross']) ? $posted['payment_gross'] : '';
$first_name = isset($posted['first_name']) ? $posted['first_name'] : '';
$last_name = isset($posted['last_name']) ? $posted['last_name'] : '';
$payer_email = isset($posted['payer_email']) ? $posted['payer_email'] : '';
$subscr_date = isset($posted['subscr_date']) ? $posted['subscr_date'] : '';
/**
* At this point you can use the data to generate email notifications,
* update your local database, hit 3rd party web services, or anything
* else you might want to automate based on this type of IPN.
*/
if($item_name == 'ATF Donation') {
$to = $payer_email;
$subject = 'Email from Adaptive Training Foundation';
$message = 'Thanks for donation';
$headers = array('Content-Type: text/html; charset=UTF-8');
wp_mail( $to, $subject, $message, $headers );
} else {
// No email
}
}
?>
我试图解决它几天。但没有运气。提前感谢您的帮助。
【问题讨论】:
标签: php wordpress email paypal paypal-ipn