我尝试使用wp_mail发送邮件。我做了以下事情:
add_action ('publish_party', 'party_contact_suppliers');
function party_contact_suppliers($post_id){
$post = get_post($post_id);
// get the address cache
$address_cache = get_option( 'toolset_maps_address_coordinates' );
$alerts = new WP_Query (array (
'post_type' => 'alert',
'post_status' => 'publish'));
foreach($alerts as $alert) {
// find the address within the cache
foreach ($address_cache as $key => $value) {
if ( $value['address'] == $alert->center-location ) {
$lat = $value['lat'];
$lon = $value['lon'];
break;
}
}
$to = $alert->post_author;
wp_mail('myemail@gmail.com','New Party Published', 'Author : '.$to.' Latitude : '.$lat.' Longitude : '.$lon);
}
return 0;
}
由于某种原因,这已经开始了无限循环的邮件。数据库中只有2个警报。
有人能看出为什么这只是永远循环吗?