• I need a schedular to automatically update the wordpress website with the new csv after a certain interval.
    I found many examples of wp_schedule_event but all were creating cron job on activation of plugin. If i do the same then code executes.But my requirement is to schedule it on submitting a form by admin.
    My requirement is:
    After plugin activation the admin will select the interval. On submitting this form i want to set the schedular to automatically check for the csv with the interval (selected by admin) so that the site will be updated automatically through new csv.
    This is my code:
    On form submittion i am calling a php page. On that page, i have written this code-

    $interval=$_POST['select_interval'];
    		require_once (str_replace ( '//', '/', dirname ( __FILE__ ) . '/' ) . '../../../wp-config.php');
    if( !wp_next_scheduled( 'mycronjob' ) ) {
    				wp_schedule_event( time(), $interval, 'cronjob',$arguments);
    			}
    		}
    add_action ('cronjob', 'update_csvSchedular');
    		function update_csvSchedular($args){
     //code to check for csv
    }

  • The topic ‘Can a schedular be set on submit of a form in wordpress?’ is closed to new replies.