我似乎无法让这段代码工作。我正在尝试通过动态检索作者的电子邮件地址来更改 Gravity Forms/Wordpress 上的通知电子邮件。
如果我将作者的电子邮件地址硬编码到 '$notification['to']',则下面的代码有效。
我只是不确定我一定做错了什么。
感谢帮助。谢谢。
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;
}