Shortcode being called multiple times on page load
-
I’ve created a plugin that has a shortcode which uses wp_mail() to send the user an email when they land on a quiz Thank You page. The email address is retrieved using the quiz provider’s API. It works well, but sends the user 4 emails instead of 1. I’m guessing it has to do with my SEO plugin loading pages multiple times—people in other threads have had luck disabling it. I’m working on a large and popular site, so I don’t want to disable the plugin and mess up the SEO. I’ve also tried putting my PHP code in a page template instead of a shortcode, the same behavior occurs.
If I call wp_die() after the wp_mail() line, only 1 email is sent, but then the page displays an error. I want to show my Thank You page and send the email.
Suggestions would be very appreciated! Thanks in advance.
- The topic ‘Shortcode being called multiple times on page load’ is closed to new replies.