Skip Navigation

[Resolved] Adding Reply-To-Email only in one email-notification of CRED

This support ticket is created 7 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

This topic contains 2 replies, has 2 voices.

Last updated by dianaM-4 7 years, 7 months ago.

Assisted by: Nigel.

Author
Posts
#437367

I am trying to add a "reply-to-"email-address to a specific notification, like posted here: https://toolset.com/forums/topic/setting-from-et-reply-to-fields-with-cred/page/2/

My CRED-form sends two e-mail-notification: One to the user and another one to my admin. I only want to have the reply-to-email-address in the second notification. Therefore I tried to set the $notification_counter to "1". Like this:

add_filter('cred_mail_header', 'add_replyto', 10, 4);
function add_replyto($headers, $formid, $postid, $notification_counter) {
    if ( $formid === 793 && $notification_counter == 1 ) {
        $useremail = get_post_meta($postid, 'wpcf-anfr-email', true);
        $newheaders = array( 'Reply-To: '.$useremail ); 
        return array_merge($headers, $newheaders);
    } 
}
add_filter('cred_mail_header', 'add_replyto', 10, 4);
function add_replyto($headers, $formid, $postid, $notification_counter = 1) {
    if ( $formid === 793 ) {
        $useremail = get_post_meta($postid, 'wpcf-anfr-email', true);
        $newheaders = array( 'Reply-To: '.$useremail ); 
        return array_merge($headers, $newheaders);
    } 
}

Both examples do not work: The first one doesn't add the reply-to to any notification, the second one to both of them. So it seems, that the notification_counter doesn't work as I expected?

Please for help! Thanks, Diana

#437510

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi Diana

The latest release of CRED added the ability to name your notifications to make it easier to manage multiple notifications.

I just took a look at the source code and the filter has been modified to add another parameter for the notification name (so you can refer to it with that rather than the number if you wish).

What you are doing isn't working because notification number is now the fifth parameter.

The parameters for cred_mail_header as now as follows:

$headers, $formid, $postid, $notname, $notnum

where the last two are notification name and notification number.

I see that our documentation hasn't been updated, and I am creating an internal ticket for our documentation team up amend it.

#437523

Okay, thanks Nigel.
$notnum doesn't work here on my localhost. Perhaps you wanna try, if there is a bug. I guess, both of the notification have the number 0. But that's just a guess …

For me, the issue is resolved, because $notname works out for me.
Thanks again! Diana

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.