Startseite › Toolset Professional Support › [Gelöst] Trouble setting Reply-To on CRED emails
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.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | - |
- | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | - |
Supporter timezone: Asia/Kolkata (GMT+05:30)
Dieses Thema enthält 21 Antworten, hat 2 Stimmen.
Zuletzt aktualisiert von Steve Palm vor 3 Jahren, 3 Monaten.
Assistiert von: Minesh.
I am hopeful you are able to point out the error of my approach, your support has been excellent up to this point. 🙂
** Tell us what you are trying to do?
We have a form for a user to request more information about a listing on the site. We don't want to disclose the email of the listing maintainer, so are using an "information request" form to submit the viewer's contact details to the listing author so they can contact them. I have found information about using the cred_mail_header() hook, but it does not seem to be called.
** Is there any documentation that you are following?
https://toolset.com/forums/topic/setting-from-et-reply-to-fields-with-cred/
https://toolset.com/documentation/programmer-reference/cred-api/#cred_mail_header
https://toolset.com/course-lesson/send-notifications-when-someone-submits-the-form/?utm_source=plugin&utm_campaign=forms&utm_medium=gui&utm_term=email-notifications
** Is there a similar example that we can see?
No, as it is only the outbound notification email.
** What is the link to your site?
versteckter Link
I have put some error_log() statements in the plugin I wrote to hook into the 'cred_mail_header' hook. I see the plugin file is indeed activated and loading, but the error_log() inside the hook function is never called.
The plugin is very simple:
[code]
function cmic_set_replyto_info_request( $headers, $formid, $postid, $notification_name, $notification_number ) {
error_log( "set replyto called" );
if ($formid==3978 && $notification_name=='Information Request') {
$myheaders = array( 'Reply-To: '.$_REQUEST["sender-email"] );
return array_merge($headers, $myheaders);
}
return $headers;
}
add_filter('cred_mail_header', 'cmic_set_replyto_info_request', 10, 5);
[/code]
Hello. Thank you for contacting the Toolset support.
That is really strange. That means the hook is not called or something still is missing.
Can you please share problem URL where you added the form as well as admin access details.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
Thank you, Minesh. I do not know why the hook is not being called, but hopefully your greater experience will triumph here and find out why. 🙂
You can view the test listing I made and use the Request Information to see the form that is sending the email:
versteckter Link
Can I run few test on the site for which you shared the access details?
It is a live public site, but if you make respectful listings and remove them when finished, it would be OK to test. That is why I made the duplicator backup for you, so that you could create a local copy, but I understand the desire to test in-place.
Can you please try to use the following code and check if that helps:
function cmic_set_replyto_info_request( $headers, $formid, $postid, $notification_name, $notification_number ) { error_log( "set replyto called" ); if ($formid==3978 && $notification_name=='Information Request') { $myheaders = array( 'Reply-To: '.$_REQUEST["wpcf-sender-email"] ); return array_merge($headers, $myheaders); } return $headers; } add_filter('cred_mail_header', 'cmic_set_replyto_info_request', 10, 5);
I think you missed the most basic point...
As I stated originall, ** the error_log() inside the hook function is never called**. It is even outside the comparison of formid and notification_name, so I would expect to see it logged for every form that sends an email, and yet it is never called at all. If I do put an error_log() in the top level of the plugin code to show that the plugin is loading and active, it does fire.
So for some reason the 'cred_mail_header' filter simply appears to never be called.
I checked on your install and I do not have access the the theme files. It looks like you added the code you shared to the functions.php file.
Can you please share FTP access details.
I have set the next reply to private which means only you and I have access to it.
This is not the case.
The plugin is: cmic-set-inforequest-replyto
That should be in the complete duplicator dump I sent you. All the theme files and everything else should be in there as well. But I provided you the code being used. I have temporarily enabled file editing so you can see on-site data.
But I will require FTP access details to view/check the logs. Can you please send me FTP access details.
I have set the next reply to private which means only you and I have access to it.
Unfortunately, I do not have the ability to easily set up FTP access to the site.
I find it interesting, though, that I received two test emails from you, and both had the Reply-To set, but yet when I just tested it for myself it did not work. What did you do to send those emails?
I have installed a plugin that shows recent error_log() entries on the main WP Dashboard page, will that help?
Can you please check now.
I've changed the code you added to your plugin file as given under:
function cmic_set_replyto_info_request( $headers, $formid, $postid, $notification_name, $notification_number ) { error_log( "set replyto called - minesh" ); if ($formid==3978 && $notification_name=='Information Request') { // error_log( "set replyto called: Form: " . $formid . " name: " . $notification_name ); $myheaders = array( 'Reply-To: '.$_REQUEST["wpcf-sender-email"] ); return array_merge($headers, $myheaders); } return $headers; } add_filter('cred_mail_header', 'cmic_set_replyto_info_request', 8, 5);
And I can see the error log is logged with the string "set replyto called - minesh".
Yes, I see it firing when you tested, but why was it not working before? Do you have an answer? Because the error_log() is the first thing in my version and in yours, but it was not working before. Do you have an answer?
Oh, I see, you lowered priority from 10 to 8.
Yes - exactly 🙂
And also changed the following line of code from:
$myheaders = array( 'Reply-To: '.$_REQUEST["sender-email"] );
To:
$myheaders = array( 'Reply-To: '.$_REQUEST["wpcf-sender-email"] );