Skip Navigation

[Resolved] Issues with forms notifications

This thread is resolved. Here is a description of the problem and solution.

Problem:
Issues with forms notifications -How to set Reply To and From emails using Form's email notification

Solution:
You can use Toolset Form hook "cred_mail_header" to set the email headers on fly and set "reply to" and "from" email notification headers.

You can find the proposed solution in this case with the following reply:
=> https://toolset.com/forums/topic/issues-with-forms-notifications/#post-1869861

Relevant Documentation:
=> https://toolset.com/documentation/programmer-reference/cred-api/#cred_notification_recipients
=> https://toolset.com/documentation/programmer-reference/cred-api/#cred_mail_header
=> https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/

This support ticket is created 3 years, 11 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.

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)

This topic contains 18 replies, has 3 voices.

Last updated by HOP 3 years, 11 months ago.

Assisted by: Minesh.

Author
Posts
#1866229

HOP

Hi, I have Toolset Forms on two sites and have several issues on them. They are:

ISSUE 1 - Website A - Form A:
I have a new website that was completed by a developer, whom I can only describe as being incompetent or inexperienced with Contact Forms/Toolset.

He used Toolset Forms to create forms on 2 websites. On one website (A) there is a conditional logic form (Form A) which basically remembers what the user selected on the homepage on a quick booking form and then after clicking 'go' it takes them to the next page where it gives them more options to fill out but it shows the boxes they filled out on the previous page already pre-populated. This form fires fine and submits, but on the Admin notification email that now comes through to us it does not show us what the customer selected in terms of the pre populated aspects. So the field settings need fixing on this form.

ISSUE 2 - Website B still has this issue
Throughout all the forms I had an issue in that they only alert the customer to notify that their enquiry has been received and that a member of staff will be in contact shortly. It doesn't however, alert us (admin) the client that a customer has submitted a contact form.

ISSUE 3 - Website B:
After many hours of investigating, talking to gsuite, g suite groups, using smtp, talking to hosting and domain companies, I managed to fix this issue on one of the websites. The solution was to change the 'Local Mail Delivery Exchanger' to the 'Remote Delivery Exchanger' option in the Configuration of the Email Routing in the cPanel Admin. However, on the other site the hosting is with IONOS and they are really crap service without any option of a cPanel area for me to change this setting.

ISSUE 4 - Website A & possibly Website B when it is fixed
On the Website A that I have managed to receive the email to us (Admin), everytime we try to reply to an enquiry, it doesn't allow us to reply to the customer, it puts our own company email in the 'To' field, so the Reply-to setting needs to be changed somewhere in WordPress, but I can't see how to change it in the Toolset Form because there's no setting to do it. Perhaps in the CREDform code? text?

One moment, please, so I can read the descriptions you added.

Ok, sure, i also don't know if those screenshots help you but they seem to be showing some errors.

Credentials:
FOR iAutoUK.com:

There is also a staging site I've set up for this site which is staging2.iautouk.com/wp-admin if you wish to test things on there too.

#1866757

HOP

Hi Jamal, Thanks for creating the thread. Are we any further with the issues at all?

#1866891

Hello Talveer,

I assume that the missing pieces of information in the admin notification are the following, right:
- Car manufacturer
- Service Enquiry
- Maybe also "Service categories", but it is not on the form.

Regarding "Car manufacturer", it is added to the form using a generic field, populated by a view. The generic field, by desing, is not saved on the database. I would expect a custom code(in the theme's functions.php file, or a separate plugin, or a snippet in Toolset->Settings->Custom code) that will save the value of this field on the database.
Car manufacturer is a taxonomy assigned to the custom post type. I would suggest using a taxonomy field instead of a generic field. We will need a custom code to select the appropriate manufacturer in the form when we came from the front page form.
Check this example https://toolset.com/forums/topic/default-value-select-taxonomy-term-in-cred/

"Service Enquiry" is actually a parent in a one-to-many relationship. We'll need to use Toolset shortcodes and the item attribute to get its value. We will also need to use a content template that will return the information of the parent post.
The notification will include the content template by passing the placeholder "%%POST_ID%%" to the item attribute as follow:

[wpv-post-body view_template="name or slug of the content template" suppress_filters="true" item="%%POST_ID%%"]

The content template will pass the parent post to the item attribute as follow:

[wpv-post-link item="@service-enquiry.parent"]

Read more about the item attribute here https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/

Regarding the subject of the email, you can use Toolset shortcode by passing the "%%POST_ID%%" to the item attribute. For example for the name of the user:

[iAutoUK] New enquiry from [types field='enquiry-first-name' item='%%POST_ID%%'][/types] [types field='enquiry-last-name' item='%%POST_ID%%'][/types]

You can check my notification example on the form. Check this hidden link

Regarding the "Reply to", that will need custom code that you can add to a child theme functions.php file or as a snippet in Toolset->Settings->Custom Code. Check these similar tickets for examples and let me know if you need help with it:
- https://toolset.com/forums/topic/emails-from-a-toolset-form-needs-to-reply-to-the-person-who-submitted-it/#post-1457297
- https://toolset.com/forums/topic/form-notification-e-mail-from-can-use-custom-field-like-email-used-in-form/#post-1277791

Regarding the issues on the second website I have replied in your other ticket https://toolset.com/forums/topic/awaiting-help-with-2-sites/

I hope this helps. Let me know if you have any questions or if you need further assistance.

All the best.
Jamal

#1867163

HOP

Hi Jamal, thanks for the reply. I will be honest, this is a bit over my head and ideally should have been done by the developer that built the site but unfortunately, he left it incomplete and gave up.

Issue 1: Regarding the Taxonomies element - are you able to just fix this as I'm confused with what I have to do, where I have to do it and if you've already completed part of it on your side.

Issue 2: Not receiving Admin emails for Site 1 and Site 2
Whilst awaiting your reply, I had pointed the domain towards a copy of the that I have moved the site 1 to a new hosting provider a few days ago and I have updated the subject and to fields of the forms as per what you had. (just need to add your own emails in the to field). What this means is that I am in a way back at square one with the problem of not receiving the Admin notification at all now. This is because on the previous host, the way I got round not receiving any Admin notifications was to change the local mail delivery to remote mail exchanger delivery in the email configuration options, but the new hosting provider has no such option and there's is set to Auto. Unfortunately, when it was set to Auto on the previous host, it would not work, it only worked when set to external mail exchanger delivery. I believe the issue is because it's trying to email itself from itself. i.e. the to address and the sender address is the same. Therefore, the host isn't accepting any responsibility for this and G Suite have accepted said it's not a fault at their end because in their Email Log report which shows and emails rejected by their servers - there are no records of the emails appearing there. So it is not them. Both the hosting provider and G Suite recommended using a the WPSMPT plugin which I was already using and they have suggested it is something within Toolset/the form that needs to be set in a certain way to allow the emails to go through.

This seems to be further backed up by the fact that if i test a submission with another form (you will see a test contact form page within WP) it delivers everywhere absolutely fine. Furthermore, on the site I reported a problem on that form has the same issue, but they have different providers to site 1 for their domain, email hosting and web hosting yet they still have the same issues as site 1 - the common thing they have is that they are both using Toolset Forms.

Another issue I have spotted is that The service categories don’t show on the populated page form for the request a booking page. I will send the screenshots on the other ticket. Also, regarding your reply on the other ticket - you referenced a screenshot but there was nothing attached.

Please can you fix these issues asap from your end, otherwise the time this is taking I am seriously considering abandoning Toolset altogether. I really appreciate your assistance but this is causing so much bother, hassle and stress and tbh should have been completed by the developer that built the site.

#1868059

Hello Talveer,

I understand the frustration that you may feel because of these forms' notifications issues and I'll do my best to help. However, for support rules, we are able to handle only one issue at a time. This helps us to bring you a better service and also helps other users to find all the information here exposed.

At the same time, this helps us(we and you) to be more focused on one issue and handle it quickly. For that reason, I suggest that we fix the "Car manufacturer" issue here and we continue each other issue(on the same site iAutoUK) on separate tickets.

Issue 1: Regarding the Taxonomies element - are you able to just fix this as I'm confused with what I have to do, where I have to do it and if you've already completed part of it on your side.

We can easily add the taxonomy field with one line:

[cred_field field='marque' force_type='taxonomy' output='bootstrap' display='select' single_select='true']

Replacing the generic element:

[cred_generic_field type='select' field='marque' output='bootstrap' class='form-control' urlparam="make"]
        {
        "required":0,
        "options":[ [wpv-view name='select-json-options-marques'] ]
        }
      [/cred_generic_field]

But, this will create another issue. The selected manufacturer from the homepage will not be selected automatically. The generic field is using the view "Select JSON options: Marques" that handles this. But, as it is a generic field, it is not automatically saved to the enquiry post, and thus it is not sent in the notification email. We can work around it with custom Javascript code that will select the manufacturer. But here too, we have an issue, the homepage uses slugs for the manufacturer terms, and the form taxonomy field uses IDs. So, I am updating the view to include the taxonomy ID too. Then I am hiding it inside the form, and I'll use the following Javascript code to select the manufacturer:

jQuery(function($){
  var maker = $('#jts-hack option[selected]').data('id');
  $('select[name="marque[]"]').val(maker);
})

Check this screenshot hidden link

I run a test and it fixed it as you can see in the customer notification email for my last test hidden link

Issue 2: Not receiving Admin emails for Site 1 and Site 2

I think that the issue is from the recipient configuration. It is probably a bug, but I need to check on a clean install before being sure. I changed the configuration on this screenshot with only one email and it works hidden link
I removed the bcc part and I am sure you will receive the notification now.

Let me please some time to check how to add the "bcc" email and the "Reply to" header and I'll get back to you.

#1868107

HOP

Hi there, thanks for this.

Issue 1: Thank you for fixing it but i need the service enquiry to be shown as well as the manufacturer selected please? So not jus the Marque, but the Second thing selected from the homepage too please.

Issue 2: i can confirm we were already receiving emails - i emailed you on the other ticket confirming that we are. I also updated the placeholders in a way that was fine. So not sure if you've undone anything, but that's all fine.

Issues 3: The 'Service required' element after it populates on the next page, upon clicking go on the book a service section on the homepage. When you get to the next page still shows the incorrect dropdowns - it shows audi servicing, bmw servicing etc... it should show mot, wheel alingment etc... Something is not mapped correctly. can you take a look please?

Issue 4: the reply-to issue still exists i believe, unless you've fixed it?

I am now receiving emails to Site 2 (I have been since the early hours of last night) but they are not able to reply to the customer by clicking reply.

#1868199

HOP

Hey Jamal,

How are you getting on with this? Any luck? Can i get an answer on this asap please? I really need it fixing, as i need to put Google ads live today without fail.

Thanks

#1868939

HOP

Hi can I get a reply on this pls? I see you're going to be off tomorrow and Thursday, so I need this to be done today, please.

#1869069

HOP

Hi Jamal, why am I not getting any replies? Ive got several tickets open and they haven't had responses on for over 24 hours (1 around 21 hours). I am not happy with what I am paying for. I have provided everything asked of me and am being very patient but this is taking too long. Please get back to me about the issues asap.

#1869783

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Jamal is off. This is Minesh here and I'll take care of this ticket. Hope this is OK.

As Jamal requested, lets focus on one issue at a time that will help us to resolve your issue step by step. That will be quick and effective way to handle the issue.

As Jamal shared his feedback with the following reply:
https://toolset.com/forums/topic/issues-with-forms-notifications/#post-1868059

Can you please describe where exactly you want help and what issue you would like to fix first. Please share all required details.
- Where I can see the issue? What will be the problem URL?
- what is your expected result?
- What issues are fixed not and with what issue you are still looking for help.

#1869835

HOP

Ok, please do take ownership of this so I am not left aimlessly waiting and having to explain the same issues countless amounts of times. I'll summarise the remaining issues below to help you to help me. Given that I've been waiting for a fix since Saturday and I am paying for support, I'd like them fixed within the day please.

Issues Remaining:

Site Name: iAutoUK.com
Issue 1: The to, from and reply-to all still say croydon@iautouk.com instead of the customer's email. and thus (see previously sent screenshot). This means when we get an enquiry and click reply it doesn't reply to the customer.

Site Name: iAutoUK.com
Issue 2: Despite selecting the 'Request a Booking form' service required options on the homepage - when it comes through to the hidden link page, it doen't show the drop down of services it should, such as mot, wheel alignment etc... instead it shows Car Servicing, then BMW Servicing, Audi Servicing, Skoda Servicing and so .... which is incorrect.

Site Name: iAutoUK.com
Issue 3: To Jamal I wrote: I tried to capitalize on the placeholders you entered into the subject field by attempting to add the 'marque' (make of the car selected) and the @service.enquiry - but it didn't come through. Perhaps I did it wrong?

Site Name: iAutoUK.com
Issue 4: I wrote to Jamal: 'Also not sure if you're working on the issues, but all the pages within the About Us Nav Menu drop down including the 'Get A Quote' page (when you click go from the homepage) now have a different font from what it should be. if you check any of the servicing pages, you will see the difference. Please can you ensure this is changed back to be uniform text throughout the site' from before you started working on the site?

Site Name: Fogizar.co.uk - (the fix to issue 1 from iAutoUK could quite possibly fix this issue too)
Issue 5: The to, from and reply-to all still say contact@fogizar.co.uk instead of the customer's email. and thus (see previously sent screenshot). This means when we get an enquiry and click reply it doesn't reply to the customer.

Feel free to look through the history on both tickets at all the screenshots to assist you in fixing the issues. Should you require anything else from me, please let me know. Logins for both sites have already been provided to Jamal.

Regards,

Talveer

#1869861

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Thank you for sharing all issues but lets focus and fix the issues one by one.

Site Name: iAutoUK.com
Issue 1: The to, from and reply-to all still say croydon@iautouk.com instead of the customer's email. and thus (see previously sent screenshot). This means when we get an enquiry and click reply it doesn't reply to the customer.
===>
Ok.

So, to setup the email headers Toolset forms offers the following hook: cred_mail_header

For example - I've added the hook "cred_mail_header" to "Custom Code" section offered by Toolset:
> hidden link


function func_set_notification_headers( $headers, $formid, $postid, $notification_name, $notification_number ) {

    // setting reply to for "Customer notification" email notification
    if ($formid==9685 && $notification_name=='Customer notification') {
        $myheaders = array( 'Reply-To: croydon@iautouk.com' );
        return array_merge($headers, $myheaders);
    }
  	
  // setting reply to for "Admin notification" email notification
  if ($formid==9685 && $notification_name=='Admin notification') {
     $user_provided_email = get_post_meta($postid,'wpcf-enquiry-email-address',true);
        $myheaders = array( 'Reply-To:'.$user_provided_email );
        return array_merge($headers, $myheaders);
    }
    return $headers;
}
add_filter('cred_mail_header', 'func_set_notification_headers', 10, 5);

To send the BCC, I've added hook "cred_notification_recipients":

add_filter('cred_notification_recipients', 'func_setup_bcc_notification_emails', 10, 4);
function func_setup_bcc_notification_emails($recipients, $notification, $form_id, $post_id) {
 
    
  if ( isset($notification['name']) && 'Admin notification' == $notification['name'] and $form_id==9685){
 
        // Add a BCC to log@emailaddress.com
        $recipients[] = array(
            'to'        =>  'bcc',
            'address'   => 'info@hopltd.co.uk',
            'name'      =>  '',
            'lastname'  =>  ''
            );
    }
          
    return $recipients;
}

More info:
=> https://toolset.com/documentation/programmer-reference/cred-api/#cred_notification_recipients
=> https://toolset.com/documentation/programmer-reference/cred-api/#cred_mail_header
=> https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/

Then I checked with the contact form: hidden link

I can see the Reply-to: is showing correct email address for both the notifications "Customer" and "Admin".

Can you please confirm it works as expected now.

#1869939

HOP
Screenshot 2020-12-09 at 10.57.24.png
Screenshot 2020-12-09 at 10.57.13.png

Hi Minesh, thanks for the reply. It is working on the contact us page (thank you so much) but not on the get a quote page (Request a booking form) hidden link - it is reached by clicking the Go button on the homepage section called book a service. - (please see attached screenshots).

ANOTHER ISSUE
ISSUE 5:
Also, whilst we're on the topic of the booking form - it doesn't display in the email notifications received what they enquiry is - i.e n this case it was MOT which from the URL it appears it was vehicle service=9228. Can you please fix this?

ISSUE 6:
When a person selects the options on the homepage book a service widget and clicks go it populates through to the Get a quote page but on the drop down it shows all the car's servicing instead of things like wheel alignment, mot etc... and when you click the drop down (on the get a quote page) and click off it it jumps the page down to the footer - really strange. please take a look.

#1870019

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

(Request a booking form) hidden link - it is reached by clicking the Go button on the homepage section called book a service. - (please see attached screenshots).
==>
I've adjusted the code as given under to "Custom Code" section offered by Toolset:
- hidden link

function func_set_notification_headers( $headers, $formid, $postid, $notification_name, $notification_number ) {
    
    // setting reply to for "Customer notification" email notification
    if (($formid==47623 or $formid==9685) && $notification_name=='Customer notification') {
        $myheaders = array( 'Reply-To: croydon@iautouk.com' );
        return array_merge($headers, $myheaders);
    }
  	
  // setting reply to for "Admin notification" email notification
  if(($formid==47623 or $formid==9685) && $notification_name=='Admin notification') {
     $user_provided_email = get_post_meta($postid,'wpcf-enquiry-email-address',true);
        $myheaders = array( 'Reply-To:'.$user_provided_email );
        return array_merge($headers, $myheaders);
    }
  
    return $headers;
}
add_filter('cred_mail_header', 'func_set_notification_headers', 10, 5);

add_filter('cred_notification_recipients', 'func_setup_bcc_notification_emails', 10, 4);
function func_setup_bcc_notification_emails($recipients, $notification, $form_id, $post_id) {
 
    // Check notification name matches target notification
  if ( isset($notification['name']) && 'Admin notification' == $notification['name'] and ($form_id==9685 or $form_id==47623)){
 
        // Add a BCC to log@emailaddress.com
        $recipients[] = array(
            'to'        =>  'bcc',
            'address'   => 'info@hopltd.co.uk',
            'name'      =>  '',
            'lastname'  =>  ''
            );
    }
          
    return $recipients;
}

Can you please confirm it works as expected with your another form as well.

Then, I will focus on another issues you shared and will split the ticket and you are welcome to mark resolve this ticket.

#1870129

HOP
Screenshot 2020-12-09 at 12.04.31.png

Hi there yes that works and replies to the consumer! Great thank you for sorting that out.

It does however display the make again of the car selected randomly to the side of the box (next to the car registration) - can you fix this please? (see screenshot)

New threads created by Minesh and linked to this one are listed below:

https://toolset.com/forums/topic/split-remove-the-unwanted-text-from-email-notification/