使用GravityForms更改通知电子邮件时遇到问题

时间:2017-07-29 21:56:35

标签: php wordpress gravityforms

我似乎无法使此代码正常工作。我试图通过动态检索作者的电子邮件地址来更改Gravity Forms / Wordpress上的通知电子邮件。

如果我将作者的电子邮件地址硬编码为' $通知['至']'

,则以下代码有效。

我只是不确定我一定做错了什么。

感谢帮助。感谢。

add_filter( 'gform_notification_19', 'change_notification_email', 10, 3 );
function change_notification_email( $user_email, $notification, $form, $entry ) {


    //There is no concept of admin notifications anymore, so we will need to target notifications based on other criteria, such as name
    if ( $notification['name'] == 'Applicant' ) {

        global $post;
        $author_id=$post->post_author;
        $user_email = get_the_author_meta( 'user_email' , $author_id );

        // toType can be routing or email
        $notification['toType'] = 'email'; 
        $notification['to'] = '$user_email';

    }

    return $notification;
}

1 个答案:

答案 0 :(得分:0)

根据法典,这应该有效。还要尝试打印变量以查看它们是否获得了正确的值。此外,您的过滤器是否正确?

<script>

    var uid = "..."; // this retrieves some variable from external server
    @ViewBag.someId = uid;

</script>
...
@If(Model.AppDataFbId == ViewBag.someId){ ... }