You can’t schedule a future email from wp_mail * but you can use wp_schedule_single_event to run in 24 hours time, and write an action hook handler that calls wp_mail() to send your mail, e.g. something like
wp_schedule_single_event( time() + (60*60*24), 'send_new_user_next_day_email', args( $userId ) );
function send_new_user_next_day_email( $userId ) {
// look up the user and call wp_mail()
}
add_action( 'send_new_user_next_day_email', 'send_new_user_next_day_email', 10, 1 );
Note that this runs on the WordPress cron system and so will trigger when you next get traffic on the site after the 24 hours are up. You can however set up system scheduler events to trigger cron events even when there’s no website traffic – see the wordpress.org cron docs.
*
unless the mail server you’re sending through supports it, e.g. Office 365 does, but I’m not sure what mail headers etc. you’d need to set up to do that.
Related Posts:
- When to use Exceptions vs Error Objects vs just plain false/null
- WordPress “phpmailer_init” not working for me
- WordPress URL Rewrite not working
- Detect a focus on wp_editor
- simple wordpress ajax plugin not working when not logged in
- Utilize WP-CLI from inside WordPress, not SSH
- Saving metabox repeatable fields
- how to create and show sessions in word press?
- Disable External Pingacks on WordPress Posts and Only Allow ‘Self Pings’
- Loading page template into shortcode
- Mail not sent when I set HTML headers
- Error when requesting password reset email – wp authentication
- do not show web page section when using advanced custom fields pro
- How to get all existing post types
- New Plugin Review
- Create custom blocks for bootstrap
- allow users to publish without admin approval
- Query String being Removed Creating a Pagination Issue within a Custom Plugin
- wp_insert_post() is returning the correct post ID, no failure, but the post content does not get updated
- What does $wpdb->get_row return?
- Redirect to another page after submission using wp_mail
- WordPress Scheduled Event Request Blocking
- Delete a WordPress transient from a shortcode on Page/Post update
- Plugin CSS not enqueing
- PHP Fatal error: Uncaught mysqli_sql_exception: Table doesn’t exist in wordpress/wp-includes/wp-db.php
- How to set up VS Code for WP plugin/theme development in 2021? [closed]
- Saving an array of dynamic repeater data as post_meta
- WordPress wpform plugin submit and get multiple checked value from checkbox [closed]
- Improve page speed loading using CDN and async or defer attribute
- Script to browser problem PHP
- Store a default value for a transient on plugin activation
- How wp-cron can run in background if PHP is single threaded?
- wp query foreach deleting record returning only first or last item
- How to retrieve the sender email with wp_mail()?
- PHP > Scheduled Tasks > Sending daily email with dynamic API variables
- wp_mail file attachment not being placed in upload folder?
- WordPress Custom field Colors
- “Undefined index” error when saving empty array with checkboxes
- Sending a custom form data in email through WP Mail Function
- Is it save to use eval for a jQuery callback method coming from the database?
- Scheduling an event inside plugin class is not working
- How to Change CSS Colors from Custom Plugin Settings Page
- Passing the name of selected color from the custom component to `render_callback`
- Any ideas why I am getting “I’m getting “wp-admin/admin-ajax.php 401 (Unauthorized)”
- Cant register rest routs from class instance
- wordpress frontend editor to add extra css to website
- Custom Registration username_exists / email_exists
- How can I search all plugins for composer’s vendor/autoload.php?
- PHP: How to access db the right way in plugin?
- select a single val though a table in wordpress
- WordPress – Get Posts with Category data
- How to use wp_send_json() and output the value with ajax?
- PHP using external anonymous function inside class
- Get page permalink in contact form
- Problem with inserting multiple images in gallery of each WooCommerce product programmatically
- Is it possible to access admin-ajax.php using PHP?
- Call to “admin_notices” hook from a static method
- How to Create custom block for displaying information in content section which act like shortcode
- How to detect and handle the time difference between server and user in WordPress?
- How to setup the Email piping in WordPress plugin?
- Reliable way to add nonce to HTTP Header in WordPress?
- Running SMTP Conditionally
- Getting an error when my plugin is updated, but the files update correctly
- Creating a POP Alert
- Add Pre-Defined Value to Click Counter in WordPress
- ssl redirect function is not working
- Drop down question
- WordPress Plugin Development – get_option error
- how to add new PHP page in WordPress plugin
- How can I get my WordPress plugin to receive data and relay it in an ajax/php request to a remote server that requires authentication?
- code that I can run, or a plug in to show what sql tables something pulls information from
- Automatic email message after manual user approval
- custom mailchimp form using HTTP API
- How to override theme’s public static function inside of a trait?
- pass datetime using wp_localize_script to frontend from settings page
- add custom metabox to media library custom widget
- Constant expression contains invalid operations plugin class properties visibility
- Display attached images of a page or post that are insetred using gallery
- overwrite wordpress gallery with custom gallery shortcode
- Gutenberg blocks shortcodes compatibility
- Enqueue sripts and styles only if function is called
- Save custom field on WP_List_Table
- Load script and styles using an array of resources
- Input field duplicates on form submit by jQuery
- Unable to pass variable to database
- Gravity Forms Marketo Plugin Feed [closed]
- INCOMING: Wall of code for form and $_POST, not updating custom field’s value
- Add custom filter to register data in array
- WP multisite network plugin fails to see classes loaded with spl autoload
- Trouble using wordpress functions in a pop-up modal form
- MySQL update text field with ‘
- What is this mark for “? function()” [closed]
- how can I make content from a plugin hidden when user is logged in? [duplicate]
- display php code in header using wp_head()
- Displaying custom meta box value in a custom post page
- how to check elementor is widget is active or loaded
- Create a custom plugin with dynamic child pages listing database records
- Load style and script for custom post type metabox
- Word press – JSPDF – Sending PDF as attachment from wp_mail – Special characters
- Permissions error when I use my plugin to delete comments in the front-end