• Hi,

    I am having a problem with wordpress, which is causing various emails to send multiple times from the wordpress install.

    I have done some digging and testing and I think that maybe the issue is coming from the init hook being called multiple times.

    I set up some code in the theme’s functions.php as follows:

    add_action('init', 'test_hook');
    
    function test_hook()
    {
    
    global $wpdb;
    $message = date("m/d/y H:i:s");;
    $wpdb->insert("pq_logs", array("message"=>$message), array("%s"));
    
    }

    When this is run, it actually adds more than one database entry on each page load…and it seems to be somewhere between 1 and 8 times at random. This obviously means the init process is running more than once for some reason – and I am guessing the woocommerce order complete emails and others that are showing errors use init in some way.

    The question is – why is init being loaded more than once?

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • I think init only fires once.

    Thread Starter shawaj

    (@shawaj)

    it does under normal operation.

    but for me it is firing multiple times – a seemingly random amount of times between 1 and 8.

    Any ideas why or how this could happen?

    Thanks

    mwaldie

    (@mwaldie)

    I found one case where init fires if you have missing files (every 404 error) just open the console to see what they are.

    I fixed my 404s, though, and I’m still getting inits all over the place (even when no one is on the site). I think I’m getting lots of spammers pinging and commenting, but I think I have disabled that. I’m still getting init calls. Basically, I can’t use init until I figure out why its firing so much..

    Anybody?

    Thread Starter shawaj

    (@shawaj)

    When you say open the console, what exactly do you mean?

    I found some plugins and theme errors were making it fire like 6 to 8 times. I have managed to get it down to 1 to 3, but still can’t figure out what is wrong!

    Really annoying.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Init hook called multiple times’ is closed to new replies.