You can pass arguments to the wp_schedule_single_event function:
wp_schedule_single_event($newdate, "one_day_before_event", array($post->ID));
Then if you do an add_action you can say how many arguments it will receive (in this case 1).
add_action( 'one_day_before_event', 'some_function', 10, 1 );
Then in your function you can access the variable:
function some_function($post_id) {
// Do something with $post_id
}
Related Posts:
- Is there way to run a code every time when any cron is run?
- WP cron doesn’t pass through my arguments
- How to test wp_cron?
- Cron jobs in a class
- WP Schedule Event – Every Day When First Visitor Comes
- Why Should We Use wp_clear_scheduled_hook and What it Does?
- Action Scheduler not running
- Dynamic name of cron event
- Can I run a slow action in a seperate thread?
- XML Imported Custom Posts
- add_action reference a class
- Remove parent theme action in child
- How to do_action and get a return value?
- Remove an action from an external Class
- How is WP Cron Locking implemented?
- Does the event ‘wp_version_check’ even exist? What is it doing?
- Unable to prevent function using save_post firing twice
- Difference between do_action(‘admin_enqueue_scripts’, $hook_suffix) and do_action(“admin_print_styles-$hook_suffix”) syntax
- Do WordPress’ cron’s clean up expired transients?
- Why, Where, and When to use reference pointers in filters/hooks?
- Need to execute a cron job
- Recurring scheduled task help
- What happens when wp_cron is deactivated in WordPress?
- How to make wp cron job not fire immediately?
- How Do I Make WordPress Run an Event Every Day?
- Add a Custom Field in Comment Box AFTER text area BUT BEFORE Send button
- Using wp_insert_post and post_update_meta but need to fire save_post afterward
- enqueuing React script and hooking its target div fails to load script
- PHP5, Inheritance, Singleton – action & filter hook limitations
- Having an add_action( ‘user_new_form’,) [closed]
- Using auth_redirect returns cannot modify header information
- Problem:Save Several Duplicate posts in The Database and then Error nesting level of ‘100’ reached
- How to remove an action added by a child theme of Genesis
- Scheduled Posts and wp-cron – Why don’t scheduled posts publish if too old?
- how can I use add_action with external class which the function contain 2 argument?
- Check if event was scheduled – schedule event only once
- remove_action not working with procedural function
- Woocommerce Change placement with wrapper
- Which action fire in front-end single post only
- How to notify the admin about something that happened during a cron job
- Create function in functions.php with hook name to execute URL
- How to remove unused avatar uploads in buddypress [closed]
- cron.php being constantly deleted [closed]
- Detect if Cron is Running
- Call add_action() in function wordpress
- How to remove function?
- Validate form in functions.php, send errors back to template
- Run function with linux cron job in WordPress
- Schedule cron don’t work
- What is the callback sent to add_submenu_page() invoked by WordPress?
- WP CRON on shared hosting that does not allow loopback connections?
- How can I trigger actions manually?
- When to use wp_schedule_single_event for async / non-blocking processes?
- add_action() in switch statement
- Problem with get_the_excerpt when using an add_action(‘the_content’) containing script tags
- Using Nested add_action()
- Issues When Recursively Calling wp_schedule_single_event()
- Are the hooks in the dashboard such as “load-$page_slug$” and “admin-head-$page_slug$” reliable and consistent throughout installs?
- How does task scheduler plugin implements cron that is not dependent on page load request? [closed]
- How wp-cron can run in background if PHP is single threaded?
- System Cron job not firing
- add_action and do_action
- Add “add to cart” button in WooCommerce [closed]
- Gravity Forms parameters return 1
- Code does not work in class implementation but works fine in functions.php file
- Generate payment URL in custom email [closed]
- Why is my css and js not enqueued until footer?
- Large WordPress CRON job
- W3TC manual cache flush does not work
- add_action.. will work if function is empty?
- call custom action after delete account
- Trying to write a function in an external php file to manage admin menu visibility
- Action inside another action not working
- How can I prove if wp cron is running my task if I have DISABLE_WP_CRON set to true
- register_post_type not working in wordpress 3.6
- How to use add_action inside files included by theme’s functions.php
- What do I put in the form action attr on top of form wordpress
- Set up a WP Cron scheduled event to update calculated ACF field
- WP Cron Working, but Function Not Working
- Solution for processing lots of data with CRON/API, dealing with memory/timeout issues
- WordPress sent multiple requests on update
- do_action in API call
- Setting up a cron job to auto update a custom field
- Custom query_var to get URL paramater not working
- CRON job to update wp_usermeta value each day or week based on server time
- Php cron job (wp-cron) not working
- Remove action from plugin
- How to make sure WP-CRON job loops through all posts?
- Understanding and using did_action() in a conditional statement
- Adding a conditional to work on certain pages/page templates to an add_action()
- Adapting functions from Genesis theme
- WordPress Multisite Cron Issue
- Invoke a function before the action hook
- using media_handle_sideload() to add mp4 files to Media Library
- Cron jobs repeating themselves
- WordPress can’t seem to handle tens of thousands of scheduled posts? Cron Breaks
- Passing arguments in add_action inside search template
- remove an action hook function on a plugin from a theme
- Running one-off cron jobs when WP_DISABLE_CRON is true: can I hit /wp-cron.php?
- HELP: Code To Check Status And Write Debug Entry