php - 无限 wp_mail 循环
问题描述
我正在尝试使用 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 个警报。
谁能明白为什么这只是永远循环?
解决方案
推荐阅读
- ios - 我正在尝试从 Document 目录访问视频,但出现错误“没有这样的文件或目录”
- java - 调用相同的模拟方法时如何返回不同的结果?
- python - 你如何计算二维张量的每一行的掩码平均值?
- javascript - 这个作业在 javascript 中做了什么?
- jquery - 选择动态内部元素,而不是静态容器
- sql - 从数据表中读取的 Powershell 脚本在找到值中的句号时出错
- report - 在没有命令行参数的 pytest 中自动生成 html 报告
- performance - 在 Common Lisp 中,函数和宏之间是否存在性能差异?
- bash - 如何在 git-bash 和 Visual Studio 17 中使用本地 devenv deploy 命令?
- c# - 如何通过 Flurl MultipartFormDataContent 将附件发布到 BIM 360 字段