Wordpress Gravity Form插件[帮助]

时间:2013-08-22 18:38:09

标签: php wordpress plugins wordpress-plugin gravity-forms-plugin

我的网站上有一个用户可以请求信息的表格,但有一个问题。在表单中我有一个复选框,当用户选择它时,必须将电子邮件发送到另一个地方。 (见截图)

enter image description here

enter image description here

正在发生的事情是:当两个规则匹配时,重力表单会发送两封电子邮件,但我只想根据优先级发送一封电子邮件。 我怎么能这样做?

1 个答案:

答案 0 :(得分:2)

我不相信路由会考虑个别规则的AND条件。

但是,您可以使用以下过滤器在发送电子邮件之前对其进行进一步修改:

add_filter("gform_notification", "my_custom_function", 10, 3);

或者,对于特定形式(即id = 42):

add_filter("gform_notification_42", "my_custom_function", 10, 3);

来源:http://www.gravityhelp.com/documentation/page/Gform_notification

更新

访问字段的示例如下所示:

add_filter('gform_notification_42', 'updateNotificationForForm42', 10, 3);
function updateNotificationForForm42( $notification, $form, $entry ) {
    $fields = $form['fields'];
    foreach( $fields as $field ) {
        // Here you need to provide the field with some kind of identifying mark (e.g., Admin Label).  
        // Below assumes the field you're interested in has an admin label of 'Test Me'
        if( $field['adminLabel'] == 'Test Me' ) {
            $fieldValue = rgpost("input_{$field['id']}");
        }
    }
}

重力表格developer docs有很多关于如何通过操作/过滤器进行自定义的示例。

另请参阅:http://www.gravityhelp.com/documentation/page/Fields