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
- remove_action or remove_filter with external classes?
- add_action reference a class
- Why does save_post action fire when creating a new post?
- Running WP Cron on multisite the right way
- WP Cron Doesn’t Execute When Time Elapses
- Remove parent theme action in child
- How to know what priority to use with add_action()?
- How to do_action and get a return value?
- Do WordPress cron jobs slow down page loading?
- Uncaught Error: Call to undefined function wp_generate_attachment_metadata() @ wp-cron
- WordPress cron isn’t scheduled on amazon web services
- Running WordPress on the Command Line – Turn off Delayed Output?
- Remove an action from an external Class
- Schedule WordPress Auto-Updates to only run during business hours
- Difference between do_action_ref_array() and do_action()
- How is WP Cron Locking implemented?
- Can my “add_action” function know the name of the hook calling it?
- Why is there both a save_post and wp_insert_post action?
- Does the event ‘wp_version_check’ even exist? What is it doing?
- When is admin_init Action ran?
- Can an action callback prevent the parent from continuing execution?
- remove_action in a theme
- Which action for triggering cron “wp”or “init”?
- add_action ‘manage_posts_custom_column’ in a class [closed]
- How do I enqueue a script to run inside the Gutenberg editor?
- How can I find out what functions are assigned to actions?
- 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
- Add something to beginning of the content
- Do WordPress’ cron’s clean up expired transients?
- Better handling of WP-CRON server load abuse
- Disable WooCommerce action
- When does next Cron Job run (time from now)?
- Get frequency of scheduled event
- How can I remove the WP menu from the admin bar?
- When and Where to use wp_insert_post()
- Why, Where, and When to use reference pointers in filters/hooks?
- Need to execute a cron job
- run a cron task without obstructing page load?
- crontab wp-cron.php on multisite path-based network: one for each path? Or just one for the root?
- Recurring scheduled task help
- add_action customize_register not working
- What happens when wp_cron is deactivated in WordPress?
- Running wp-cron from CLI
- How to make wp cron job not fire immediately?
- How Do I Make WordPress Run an Event Every Day?
- get_posts inside cron
- Passing arguments into ‘init’ function
- Add a Custom Field in Comment Box AFTER text area BUT BEFORE Send button
- Hourly WP schedule, do I need at least 1 visitor hourly?
- Initialize WordPress environment to use in a real cron script
- How to use conditional add_action for WordPress
- Using wp_insert_post and post_update_meta but need to fire save_post afterward
- Why?: hundreds of empty files named wp-cron.php?doing_wp_cron.
- Can’t access wp_filesystem in cron function
- enqueuing React script and hooking its target div fails to load script
- WP CRON runs only the first time
- Multiple wp_schedule_event cron jobs in plugin cause multi-execution
- wp_logout action not working
- WP Cron emails not working
- Trigger a cron every 24h GMT -8
- How to remove an action that is added inside a class
- WordPress Cron Schedule the if and else statement
- Schedule event every second thursday of the month
- PHP5, Inheritance, Singleton – action & filter hook limitations
- Having an add_action( ‘user_new_form’,) [closed]
- Using auth_redirect returns cannot modify header information
- add action which returns modified value
- What would cause the ‘wp’ action to fire twice per page (but only once per post) in Firefox only?
- Problem:Save Several Duplicate posts in The Database and then Error nesting level of ‘100’ reached
- Automated mark posts as featured every day
- How to remove an action added by a child theme of Genesis
- I don’t understand why I need a lower priority to remove an action with a higher priority to make it work
- Auto Delete Users (auto_delete_users)
- WordPress admin WP_table_list show incorrectly
- wp_get_attachment_metadata returns false with add_action() ‘add_attachment’ hook
- How to add a checkbox inside the “Publish post” widget?
- Manually add admin bar
- Is there any background process that I can run from plugin without depending on page hits on a website without affecting page-load speed?
- Is there a way to expose additional fields to the Bulk Action > Edit functionality?
- WordPress cron running twice
- What’s the usage of action do_meta_boxes?
- How can I invoke an action after a CiviCRM triggering event?
- Custom bulk actions in WP 3.7.1
- Scheduled Posts and wp-cron – Why don’t scheduled posts publish if too old?
- wp_schedule_single_event function not working
- How ( and mostly at what time ) can i prevent the alternate cron from running?
- Remove action from a plugin class
- do_action pass array argument as reference not copy [duplicate]
- How do i schedule cron in wordpress for each second?