0

I currently developing a plug that has wp_schedule_event , the purpose of wp_schedule_event to my plugin is i want my plugin so send an email depends on recurrance of the wp_schedule_event. I also have a settings form for my wp_chedule_event that allows the user to change the reccurance . {daily,twicedaily,hourly,30mins,5mins} .. When i try to change the daily recurrance to 5mins. It has no effect , the email send is still every daily(24hours) and when i try to deactivate my plugin and activate again the email send executes every 5mins. Do you have any explaination for this ? how can i make this a real time. I mean when i change it from daily to 5mins, the plugin will execute the send email to 5mins.

here is my code

    register_activation_hook(__FILE__, 'sf_contact_importer_install');
    function sf_contact_importer_install() {
        $cron_sched = get_option('inatural_sf_settings',
        array(
            'cron_schedules' => '',
            )
        );
        $cron_execute_sched = '';
        if($cron_sched['cron_schedules'] == '24hours')
        {
            $cron_execute_sched = 'daily';
        }
        if($cron_sched['cron_schedules'] == '12hours')
        {
            $cron_execute_sched = 'twicedaily';
        }
        if($cron_sched['cron_schedules'] == '1hour')
        {
            $cron_execute_sched = 'hourly';
        }
        if($cron_sched['cron_schedules'] == '30mins')
        {
            $cron_execute_sched = '30minutes';
        }
        if($cron_sched['cron_schedules'] == '5mins')
        {
            $cron_execute_sched = '5mimutes';
        }

        wp_schedule_event( current_time( 'timestamp' ), $cron_execute_sched, 'sync_sf_contacts_daily');
    }

    add_action('sync_sf_contacts_daily', 'sync_sf_contacts_daily_cron');
    function sync_sf_contacts_daily_cron() {

       wp_mail('danrylcarpio@yahoo.com','welcome','Test email body');

    }
  • What does your wp_schedule_event code look like? – czerspalace Oct 29 '15 at 5:24
  • Thankyou for your interest to help me, I edit my question. Please check again – Danryl Tigol Carpio Oct 29 '15 at 5:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.