• Derek Wilcox

    (@themassapothecary)


    I am having a problem where WordPress won’t do any scheduled tasks It won’t allow me to set auto-update on plugins and now I keep getting an error email saying Woocommerce Cart Abandonment plugin isn’t working and upon checking I see that cart abandoned emails were scheduled to be sent but never went out. Can anyone please help? I have no idea what other scheduled functions arent working either.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    Lets do a test to determine if the issue is installation-wide or an issue with the plugin only. Temporarily add the following code to your theme’s functions.php and page.php template as noted. Do not place the template code within other PHP blocks, take care to ensure it is inserted within regular HTML content. Change [email protected] to your actual email address in the functions.php code.

    // add to functions.php at the very bottom of the file
    function do_this_in_5_min() {
       error_log('The 5 min. scheduled event has executed.');
       wp_mail('[email protected]', 'Subject - Scheduled event test', 'Content - the 5 min. scheduled event has executed.');
    }
    add_action( 'my_new_event','do_this_in_5_min' );
    <?php
    // Add to page.php
    // this will schedule a new event on EVERY page visit!
    wp_schedule_single_event( time() + 300, 'my_new_event' );
    // time() + 300 = five min. from now.
    ?>

    Load any page that uses the page.php template to schedule a new task, then comment out the wp_schedule_single_event() line to stop additional events from being scheduled (add // to the front of the line). After 5 minutes have passed, view something in WP to trigger the task, which both emails you and logs a message in the error log.

    Check your error log to see if the message was logged, demonstrating that scheduled tasks do in fact work. Check your email account for a similar message. Remember that emails can take a while to get delivered and that they could land in your spam folder. If you get the email, then we know that your installation can send out emails.

    If those check out, there is likely a problem with the cart abandonment plugin itself. Take up the issue with its devs through their official support channel.

    Edited test code instructions, didn’t think through my initial post.

    • This reply was modified 5 years ago by bcworkz.
    Thread Starter Derek Wilcox

    (@themassapothecary)

    Can you please help me walk through how to do this test? How do I access my code to add this and do I add the top code to themes function PHP and second code to page PHP template? If so how?

    I am sorry I am very new to all of this

    Moderator bcworkz

    (@bcworkz)

    No worries, better safe than sorry. The easiest way to alter theme files is to use the theme editor. First, it’s advised that you switch to another theme. In WP admin, go Appearance > Theme Editor. Select your original theme at upper right. Pick the file to edit in the right sidebar. functions.php is listed as “Theme Functions”. The page template is listed as “Single Page”.

    The problem with the theme editor is it’s not easy to make backups, which is why I prefer to use FTP to get server files to my local computer where I can easily manipulate and backup files, then send altered files back to the server. But if you are not familiar with FTP, it’s much harder to explain.

    You can copy/paste theme editor content into a new plain text file (never use a word processor to do this) to make backups, or live dangerously and just remember where you made changes. It’s a good idea to first switch to a different theme so that WP does not crash if you make a mistake in editing. When you reinstate your altered theme, if there are any fatal errors introduced, WP will refuse to utilize the theme. If that happens, either fix the error or restore from backup.

    I did test my code before posting it, it is error free, but there is still a chance of introducing errors if the code is added into the wrong place. The very bottom of functions.php will be good. For page.php, any place in regular HTML will be fine, just don’t paste into existing PHP blocks delimited with <?php ?>.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Cant do any scheduled tasks’ is closed to new replies.