Add cron schedule to upload video on save_post
I made a custom plugin to get post data from another source, when I save a post, I get all data. and also upload a video from source server to our server.
But it take a while when saving post until uploading the video.
Now, When saving post I need to get all data from source, But schedule uploading video after 1 minute to upload it on background.
The Code Example:
add_action( 'save_post', 'update_from_source');
function update_from_source($post_id)
{
// code for getting post data here
function uploading_video()
{
// code for uploading video here
// I dont need to run this when saving post
// but add it as cron job for this post
}
}
How I can Add uploading_video Function to cron?