我需要在日历事件前一天和后一天发送提醒电子邮件。不幸的是,我不能使用规则调度程序,因为 PHP 不能操作令牌。如果我有它不起作用
[node:field_event_date-datetime] -1 day
作为预定时间。
我最终做的是为 DAY BEFORE 和 DAY AFTER 创建两个“虚拟”日期字段,我试图连接到表单中,获取事件日期,使用一些 PHP,如 strtotime() 来添加/减去天,并将这些值作为将进入数据库的值。
我已经尝试链接到表单的#submit 部分,但在 phpMyAdmin 中,所有值都是 NULL。对于这段代码,我什至没有更改日期,我只是试图让值出现在数据库中。
function mymodule_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == "event_node_form") {
$form['#submit'][] = '_mymodule_after_build';
// Makes the fields invisible
$form["field_event_day_before"]["#access"] = FALSE;
$form["field_event_day_after"]["#access"] = FALSE;
}
}
function _mymodule_after_build($form, &$form_state) {
$eventcopy = array();
// copy the value part from the Event
$eventcopy = $form['field_event_date'][0]['#value'];
// without doing any PHP yet, simply copy the values. Doesn't show up in db.
$form['field_event_day_before'][0]['#value'] = $eventcopy;
dsm($form);
return $form;
}
我已经阅读了有关使用规则调度程序和 CCK的教程和
我也在关注基于 CCK 日期字段的日程安排电子邮件 - 不适合我
我使用了正确的钩子吗?如何正确截取输入的日期值?