如何在12:00 am每6个月发送一封关于用户更新的日期字段的电子邮件,这是在用户配置文件中使用的规则模块?
其邮件应每6个月以循环形式发送一次通知用户,每6个月重复一次。
到目前为止,我遵循了教程"如何在Drupal 7中使用规则调度程序发送后续电子邮件",创建了一个规则组件,然后创建了如下规则:
这就是我到目前为止所做的,我想每6个月发送一次同样的电子邮件。
发布于 2015-09-30 10:55:03
规则模块和Rules Scheduler (它的一个子模块)可以用来发送这样的eMails,如下所示。
将一个字段添加到具有机器名(例如) field_next_renewal的"user“实体中。只允许一个日期(存储“下一个”更新日期)。
下面是要创建的规则组件(在规则导出格式中,只需通过复制粘贴在您自己的环境中导入它):
{ "rules_send_email_notification" : {
"LABEL" : "Send eMail notification",
"PLUGIN" : "action set",
"OWNER" : "rules",
"REQUIRES" : [ "rules" ],
"USES VARIABLES" : { "user_to_notify" : { "label" : "User to be notified", "type" : "user" } },
"ACTION SET" : [
{ "mail" : {
"to" : [ "user-to-notify:mail" ],
"subject" : "Reminder about your next renewal",
"message" : "This is a reminder about your next renewal on [user-to-notify:field_next_renewal] ...",
"from" : "[site:mail]",
"language" : [ "" ]
}
}
]
}
}显然,eMail的主题和内容可能需要审查/调优,而您也可能希望使用eMail ID中的其他内容。
创建“规则”
下面是要创建的规则,采用规则导出格式(只需通过复制粘贴在您自己的环境中导入它):
{ "rules_email_user_every_6_months" : {
"LABEL" : "eMail user every 6 months",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "rules_scheduler" ],
"ON" : { "user_insert" : [] },
"IF" : [
{ "entity_has_field" : { "entity" : [ "account" ], "field" : "field_next_renewal" } }
],
"DO" : [
{ "data_set" : { "data" : [ "account:field-next-renewal" ], "value" : "+6 month" } },
{ "schedule" : {
"component" : "rules_send_email_notification",
"date" : {
"select" : "account:field-next-renewal",
"date_offset" : { "value" : 15552000 }
},
"identifier" : "[account:name]",
"param_user_to_notify" : [ "account" ]
}
}
]
}
}上面的规则引用上一步中的规则组件。
请注意,15552000相当于6个月的秒。你可能想要减少一点,例如,几秒钟相当于几天(或一周左右)。这样,eMail就会在实际更新前几天触发。
https://drupal.stackexchange.com/questions/173717
复制相似问题