Skip Navigation

[Resolved] New Post Notification Emails are not functioning

This support ticket is created 4 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.

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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Tagged: 

This topic contains 41 replies, has 4 voices.

Last updated by Beda 4 years, 10 months ago.

Assisted by: Beda.

Author
Posts
#1249917

Hi Beda,

I tried the following and determined that the issue lies with the Avada theme.

First, I made a new form from scratch and replaced the one on the /email-entry page with that new form. Second, I modified the validation function in the child theme functions.php to verify that form. Third, I disabled all but required plugins, Toolset Views, Types & Cred, along with the minimum 2 required plugins for Avada. Re-tested and no notifications were sent.

Then, I switched to the 2019 theme and deleted all of the Filtered Email posts I had just created with the form. I then repeated the process and all of the filtered email posts were created and all of the notifications WERE SUCCESSFULLY SENT!

Then, I moved the custom validation PHP code from the child theme functions.php file and copied it to the 2019 theme functions.php. All of the emails worked correctly however, the validation did not. When I tried to add an entry for an email address that was not included in the array of allowed email domains, the function allowed through. Perhaps this is because that functions requires adjustment when the theme is changed, or perhaps placing those functions at the very bottom of the functions.php file has created that issue.

Unless I can find out why the Avada Theme is interferring with this CRED form, I will need to change themes to get the site working.

#1251933

Nigel
Supporter

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

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

Hi Patrick

Beda is off but will be back tomorrow. Given that he has a duplicate of your site and is already familiar with the issue I'll leave it for him to respond when he returns if that's okay.

#1252803

Hi Patrick, I am back.

1. If you would log into the live site and test these emails: [...] You will see that all of those emails create the Filtered Email posts currectly, but fail to send the notification to that email as CRED is configured to do.

==> I did indeed log in, send the emails, and confirmed they are not working.

You can see and read this statement in my first reply to you, here:
https://toolset.com/forums/topic/new-post-notification-emails-are-not-functioning/page/2/#post-1249815

2. It seems that the CRED notifications do send correctly from the live site unless there has been a Filtered Email post in the past

==> Notifications are not related to the post fields or posts saved or trashed, they are sent when you submit that form.
Hence there is another code in place that makes it stopping to send the emails in case some kind of entry exists already.
Having posts in the database will never stop a notification to be sent when the form is submitted since Toolset Forms simply does not provide methods to limit submits and also notifies you each time the form is submitted. If that stops once certain entries exist then it's due to additional code or plugins and not Forms native behaviour.
That'd explain why locally it works - probably some of the required steps are not happening locally. Remains to figure out which those are to solve the issue.

3. I have searched the WordPress database and have found that for every email that fails, there are posts and post meta that are labelled CRED auto-generated post

This is not possible. Toolset Forms does not store emails sent in the database.
It stores emails that you save to be sent - the blueprint so to say - but not the mail you have sent.
It also creates no posts for failed emails. It might be there is either code or plugin interrupting post creation - then you see autodrafts.

4. I modified the validation function in the child theme functions.php to verify that form.

So there is custom code validating this form.
This confirms it:

Then, I switched to the 2019 theme and deleted all of the Filtered Email posts I had just created with the form. I then repeated the process and all of the filtered email posts were created and all of the notifications WERE SUCCESSFULLY SENT!

5. It's most likely not Avada but that code.

I've checked the code and in fact, you use "already created posts with such email" to interrupt the script:

==> //check if email is already in the database
			if (count($posts) > 0){
				//set error message for my_field
				$errors['wpcf-domain-limited-email']='This E-mail is already registered. Please use the link you received via email to manage your nominations.';
			}

I am quite sure, as soon that code is removed from the Avada theme (and any related, or similar, applying to the same form) the issue will be solved
Adding custom code to Theme Twenty Seventeen Functions.php is not an issue, this work - however, with Custom Code we can help only limitedly.

The first I saw is that you return array($fields,$errors); twice.
That would be incorrect, according to the API DOC we should return it at the end:
https://toolset.com/documentation/programmer-reference/cred-api/

Can you confirm:
- using a Fresh copy of the Avada Theme solves the issue
- using a copy of the Avada theme without the above code solves the issue

If so, we have a point to start where you can then re-introduce the code you removed piece by piece to know where it fails.

Related to custom fields, I see you check upon those to verify the existence of emails, those are always attached to the post and get deleted when you delete the post.
Not when you trash the post, but only when you delete it.
Then, the meta is removed and has no more occurrence in the database unless otherwise added by code previously.

#1253103

I will test the site with and without the custom validation function. That function was provided to me by Minesh in this support ticket: <a href="https://toolset.com/forums/topic/need-to-validate-unique-values-in-post-field/">https://toolset.com/forums/topic/need-to-validate-unique-values-in-post-field/</a&gt;.

Do you have a code sample for how that validation should be properly written? I could probably use parts of that code but just need to know the syntax for placing it into the proper API Hook. Also, you should probably taint that post in which I was provided incorrect code as others are probably repeating what I did and could potentially run into the same issue.

I'll update you on the tests later today.

#1253485

Hi Beda,

I have completely removed the validation code from the child theme functions.php and the notifications are NOT working. This is currently just the Avada theme with Toolset Types, Views & Forms plugins and I am using a child theme which has not been modified.

If I fill out the form on the /email-entry page, it created new Filtered Email posts but it does not send any notifications. There is nothing in the mail log at all.

I am very concerned about this project. I have been trying to get this software to function at its most basic level following all of the instructions carefully. I have been trying to get it resolved now for more than 2 weeks and I have a very angry client who is only getting more and more upset. I have purchased the most expensive license for the software and I am hoping I have not made a mistake. Surely this issue cannot be insurmountable. Please help me get your software functioning.

#1253987

Thanks for the update.

Code samples of the Forms API can be found at the Link that Minesh Submitted along with the Custom Code sample he provided here:
https://toolset.com/forums/topic/need-to-validate-unique-values-in-post-field/#post-1201756

The code he provided only checks if there is a post with the meta value as set in the Form's field on submit.
It doesn't save anything or alter the database - it will not leave any trace on the data saved.
It can only be the cause in as far that it validates the emails and would stop the form from submitting.

I repeated the tests on your site, I had to delete the (many) emails in the logs to keep it clear.

When submitting the form (even the first time) (no such post exists yet) with my email, no email was sent.
I can also confirm, as soon I activate Theme Twenty Nineteen on your site, emails are sent.
The email is not sent either with Avada or the child theme of it, on your site.

Locally, on the duplicate, without any change, the emails are sent fine.
I also tested with your PHP version 5.6, and the emails are sent too. Remember, locally I use your theme and even the custom code.

I can at this point invite you to see this working on an online server we can create for you (it is free).
You can also confirm this by duplicating the site to another server.

I cannot spot any difference in the installs, given they are duplicates, they are identic. This points to some issue on the server, that together with Avada seems to stop Emails.
We can also try, after we agree the issue happens only on this single install, to send emails with other tools, to see if those are affected as well - that would confirm the issue to be between the theme and the server.
If we can replicate this issue on another server, and other software is not affected, it'd mean it's a conflict between Avada and Toolset + Eventually the server.
But as mentioned I cannot replicate this issue on a very duplicate of the site.

In the case this is an issue between Toolset and Avada I cannot guarantee a quick fix but we'd do everything in our power to fix it.
If the issue is only on Avada and the server, we also will contact the Theme developers with our findings and try to work out solutions.

1. Can you confirm this is not happening for you either on other installs (Remember I can provide such installs for free to test with and confirm if required)
2. Would you agree to tests after we confirm #1 above on the live site, including adding code or other plugins to send emails?

#1254417

Yes, please do whatever you need to do on the live site. I wonder if it would make a difference to delete the Avada theme and reinstall a fresh copy.

The only other significant difference I an think of is that this site was duplicated from another similar site at zerotoprotect.com. I used the UpdraftPlus WP plugin for this. Although the artwork and function is slightly different, the basic post forms were similar enough and there was enough duplicate JavaScript that I thought it would be advantageous to simply duplicate zerotoprotect.com to trynutanix.com and then make the necessary changes. That's when the notification problem emerged.

I have since made a new site with Avada and Toolset at veeamdti.com. It was written from scratch and not duplicated from any other site. All of its notifications work as expected. Such an infuriating mystery!!

#1254895

That notifications work on a fresh install is clear, but what I mean is to take a copy of the current broken site, deploy that on a new server, and things should start working again, just as in my local test.

Can you confirm this please, or let me know if you need an online server where to you can deploy your copy?
Step 2 "2. Would you agree to tests after we confirm #1 above on the live site, including adding code or other plugins to send emails?" I can do only after that.

The idea is to confirm that the issue only happens in this very install and nowhere else, which then clearly indicates a corruption of the data.
In that case, anything from rebuilding the site from the original copy to creating a new form with the notifications might help, depending on the corruption.

#1260393

I duplicated hidden link to hidden link and all notifications function as they should. Completely astounding!

Then, I completely removed the wordpress installation at trynutanix.com and did the exact same install proceedure that I did for the functioning copy. No notification emails at all!

These 2 domains are operating within the same cPanel, with exactly the same settings on the same server. I have no idea what it is about the domain trynutanix.com that seems to be killing the notifications.

#1260867

This is indeed strange, however, it just confirms what we found earlier: The issue is not replicable, on any install, not even on the same server.

This must be a corruption of that specific install, and likely we cannot help with this, it's on the server side since the same precise duplicate works on other installs.

I'd recommend explaining this to the server admin - there must be a difference in the installs on the server level, which you now can show having the second (working) test site. If this is the same precise copy and it works, then the only difference can be the install itself on the server.

#1261497

Hi Beda,

I found it. I'm using a plugin called UpdraftPlus for backup/restore. I noticed that the copy of UpdraftPlus (which is a plugin) included in the backup that I am using for testing on different servers was out of date. Each time I restore the backup, I then update that plugin.

This time, I went to fuck.trynutanix.com and deleted the backup that I used to make that site. That site is fully functional. I then made sure everything, including UpdraftPlus was updated and made a new backup of fuck.tyrynutanix.com. I completely removed the site at trynutanix.com. I did a clean install of WordPress, down to the php.ini file. I installed and updated UpdraftPlus on that clean install. I moved the freshly made backup from fuck.trynutanix.com to trynutanix.com and restored it and now, finally, all of the notifications are working.

Whatever was happening in UpdraftPlus was able to fix the notification error when the restoration went to a different domain or url. If it went to the original domain, it didn't require any changes, so the corruption was not fixed. After updating, they seem to have found and fixed this error. Site is not working properly.

Do I get some sort of trophy or plaque for having the longest, most irritating support ticket in company history? Thanks to all for the help!!

#1261967

This is great news - hence it was the migration process. I usually use Duplicator PRO or All In One WP Migration.
I never had similar issues as described here when using those plugins.

We have unfortunately no badges to provide ;D

I hope that we can help you in future in our forums as well.

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