• T

    (@tenleftfingers)


    I’ve been working on this for hours now and the usual answers don’t apply in my case.

    I’ve created a shortcode in functions.php (of the theme) to return information for display, but the function also calls another method I’ve created which sends an email (by calling mail() internally). Users are receiving the email twice and the logs show the methods are getting called twice.

    The page where the shortcode is used (once!) is https://auracolors.com/quiz-results/ and the URL is reached by a redirect that usually appends a key to specify which info to display. Either way, my method is still called and calls the email function.

    I’ve tried running test code as suggested by the host here: https://support.rackspace.com/how-to/test-php-mail-functionality/
    and *that* email only gets sent/received once, so I know it’s something on the site.

    Can anyone suggest how to proceed?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Did you figure this out? I made a shortcode containing php and it runs twice for some reason as well

    Thread Starter T

    (@tenleftfingers)

    I never figured it out. The site has since been revamped so the issue is gone.

    A suggestion from another developer was that the page might have been reloaded for some users depending on their situation and he recommended not using a shortcode on complex/dynamic pages like this.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘My function gets called twice even though I only call it once’ is closed to new replies.