Title: wp-cron syntax
Last modified: August 22, 2016

---

# wp-cron syntax

 *  Resolved [LordGoran](https://wordpress.org/support/users/lordgoran/)
 * (@lordgoran)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/wp-cron-syntax/)
 * I having some issues with the syntax for adding a hook to wp-cron.
 * Here’s what I have:
 *     ```
       register_activation_hook( __FILE__, array($this, 'run_on_activate') );
       function run_on_activate()
       {
           // for notifications
           if( !wp_next_scheduled( 'send_abandon_cart_email_hook' ) )
           {
               wp_schedule_event( time(), 'hourly', 'send_abandon_cart_email_hook' );
           }
       }
       add_action( 'send_abandon_cart_email_hook', 'send_abandon_cart_email' );
       function send_abandon_cart_email() {
       	wp_remote_get('<mywebsite>/wp-content/plugins/woocommerce-abandon-cart/cron/send_email.php');
       }
       ```
   
 * For some reason I get an error.
    Can you lend a hand on the correct syntax?
 * Thanks!
 * [https://wordpress.org/plugins/woocommerce-abandoned-cart/](https://wordpress.org/plugins/woocommerce-abandoned-cart/)

Viewing 8 replies - 1 through 8 (of 8 total)

 *  [mansishah](https://wordpress.org/support/users/mansishah/)
 * (@mansishah)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/wp-cron-syntax/#post-5769567)
 * Hi,
 * Can you please tell us about the syntax error?
 * Can you please try with the following command for function send_abandon_cart_email()
   and let us know about the working:
    function send_abandon_cart_email() { require_once(‘
   <mywebsite>/wp-content/plugins/woocommerce-abandon-cart/cron/send_email.php’);}
 * Regards,
    Mansi Shah
 *  Thread Starter [LordGoran](https://wordpress.org/support/users/lordgoran/)
 * (@lordgoran)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/wp-cron-syntax/#post-5769612)
 * Okay, I did some digging into your plugin.
    After looking at your code I found
   the underlying problem. My site is built on the Word Press Multi-site. The database
   structure for pulling the user data is not the same as the stand along Word Press
   software.
 * The error I was getting was Word Press’s way to say that it had a database error.
 * Unless you have a version of your plugin that works for the WP Multisite, I guess
   I’m out of luck.
 * Thanks!
 *  [mansishah](https://wordpress.org/support/users/mansishah/)
 * (@mansishah)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/wp-cron-syntax/#post-5769678)
 * Hi,
 * We are trying to replicate the issue you have mentioned. Can you send a screenshot
   of what you are seeing?
 * We will get back to you tomorrow.
 * Regards,
    Mansi shah
 *  Thread Starter [LordGoran](https://wordpress.org/support/users/lordgoran/)
 * (@lordgoran)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/wp-cron-syntax/#post-5769679)
 * In the Word Press Multi site database the table `users` does not exist. Instead
   the database is set up as follows:
    `wp_users` is the table for the entire multi
   site. `wp_1_` would then be the prefix to the first word press website inside
   of the Multisite.
 * So if your script is looking for `wp_1_users` it will never find `wp_users`.
 * I’m testing an edit I did to your code.
    In the get_carts function I edited the
   code to look for a hard coded table name for `wp_users` and not the $wpdb->prefix.”
   users.
 * I’ll update if it works.
 * Steve
 *  Thread Starter [LordGoran](https://wordpress.org/support/users/lordgoran/)
 * (@lordgoran)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/wp-cron-syntax/#post-5769682)
 * By editing your code I got the email script to work.
 * It took editing the table name for `Users` you have in your get_cats function
   to match the database structure I have set-up in my Word Press Multisite.
 * So if anyone else has the same issue I did, at line 134 of your send_mail.php
   change `".$wpdb->prefix."users` to the structure of your database. Like `wp_users`
   for example.
 * Steve
 *  [mansishah](https://wordpress.org/support/users/mansishah/)
 * (@mansishah)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/wp-cron-syntax/#post-5769695)
 * Hi,
 * Can you please tell us that which version for Abandoned cart lite plugin are 
   you using at multisite?
 * As we have tried to replicate the issue on our staging multisite and it is working
   fine for us.
 * Regards,
    Mansi Shah
 *  Thread Starter [LordGoran](https://wordpress.org/support/users/lordgoran/)
 * (@lordgoran)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/wp-cron-syntax/#post-5769701)
 * It’s version 1.2 The WP MU install is 3.6.
 * Like I said, in our Multisite install all users for all sites are in a single
   table. I was not the person that set this up. I’m coming in second hand, and 
   it’s been updated a few times. So I’m guessing that the base install is very 
   old and could be from when the Multisite was first available.
 * Steve
 *  [mansishah](https://wordpress.org/support/users/mansishah/)
 * (@mansishah)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/wp-cron-syntax/#post-5769745)
 * Hi,
 * I am glad to know that you can able to resolve the issue.
 * Thank you for sharing the solution with us.
 * Please let us know if any further queries.
 * Regards,
    Mansi Shah

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘wp-cron syntax’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce-abandoned-cart/assets/icon-256x256.png?rev=2369396)
 * [Abandoned Cart Lite for WooCommerce](https://wordpress.org/plugins/woocommerce-abandoned-cart/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce-abandoned-cart/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce-abandoned-cart/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce-abandoned-cart/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce-abandoned-cart/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce-abandoned-cart/reviews/)

 * 8 replies
 * 2 participants
 * Last reply from: [mansishah](https://wordpress.org/support/users/mansishah/)
 * Last activity: [11 years, 4 months ago](https://wordpress.org/support/topic/wp-cron-syntax/#post-5769745)
 * Status: resolved