wp_mail没有在wordpress自定义插件文件上工作

时间:2015-02-17 14:10:04

标签: php wordpress email

我遇到了一个奇怪的问题。我正在使用" WP电子邮件模板"插入mandrill。我也在里面使用自定义文件" theme-my-login"收到$ _POST后需要发送电子邮件的插件。这是一个代码

$location = $_SERVER['DOCUMENT_ROOT'];

global $wpdb;

if ( ! isset( $wpdb ) ) { 
    include( $location . '/wp-config.php' );
}

global $current_user;

/************** Wp_mail Works Fine when placed here *************/
if( isset( $_POST['organisation_name'] ) ) {    
/************** Wp_mail doesnot Work when placed here *************/
    $current_user = wp_get_current_user();
}

Wp邮件在外部设置($ _ POST)时工作得很好但放在里面时它不起作用。我已经加倍检查并正确执行了if语句。 编辑:这是条件之前的Print_r($ _ POST) 没什么有趣的

Array
(
    [organisation_name] => iDevels
    [representative_name] => Test Ato
    [representative_contact] => 
    [course-name] => ITIL 2011
    [course-level] => Foundation (3 days)
    [start-date] => 17/02/2015
    [end-date] => 19/02/2015
    [no-candidate] => 2
    [trainer-required] => true
    [trainer-name] => 
    [exam-required] => true
    [exam-date] => 19/02/2015
    [exam-time] => 12:00
    [exam-type] => Paper
    [proctor-name] => 
    [delivery-contact] => asdasd
    [delivery-phone] => 234234
    [delivery-address] => asdasd
    [delivery-city] => asdasd
    [delivery-postcode] => asdasd
    [delivery-country] => AT
    [exam-papers] => delivery location
    [training-venue-location] => Same as delivery location
    [training-contact] => asdasd
    [training-phone] => 234234
    [training-address] => asdasd
    [training-city] => asdasd
    [training-postcode] => asdasd
    [training-country] => AT
    [_wpnonce] => cc65d65d0c
    [_wp_http_referer] => /customer-area/?settings=order-training
)

1 个答案:

答案 0 :(得分:0)

我不确定它是如何在条件之前发送邮件的。我刚刚将mandrill设置从进行API调用更改为实际使用Mandrills SMTP设置,这解决了这个问题。