Instead of rely on global $post
, you should use the post object passed to function via the posts status transition:
add_action('pending_to_future', 'scheduledNotification');
add_action('approved_to_future', 'scheduledNotification');
function scheduledNotification( $post ) {
$author = get_userdata($post->post_author);
// the rest of your function here
}
Related Posts:
- Alert Email when any Post or Page is Changed
- Disable new user notification to admin email
- email wordpress users using BCC
- Disable WP notifications for commenting on own posts
- General Setting Allow Multiple Email Notification
- Email notification after registration in WordPress
- Send email only upon draft
- Mechanism to send to users of secured WordPress install new notifications by SMS or email?
- Is it possible to change an existing post status from ‘pending’ to ‘publish’ via email?
- User registration email and let user choose pasword
- PAGE Specific Email Notifications
- Email user on WordPress upgrade
- How to send post notification when a Author and Contributor post?
- Is it possible to not receive email notifications for comments?
- How do I troubleshoot registration/password email errors?
- Is there a way to follow a WordPress site by email alerts for new posts? [closed]
- Alternative to email notification system?
- Need to suspend RSS feed while repairing missing old post
- Email post to submitter
- New user notification issue
- E-Mail Notification on post edit
- Notification Email Address not changing
- SMTP not working for Comments Email Notifications
- Check if “Send the new user an email about their account” is ticked
- User profile update author
- How to set SMTP programmatically
- changing notification emails from WordPress @mydomain.net to something else
- Missing URL in password reset email
- prevent users from changing their email address
- Customizing the Subject Field in WordPress’ Notification Emails?
- Allow Duplicate Email Address for Different Users
- Include HTML template file in wp_mail
- Email sent from WordPress has HTML tags
- Reset Password – change from name and email address
- Send mail to wordpress admin
- WP Cron emails not working
- Few chars getting replaced with ‘=’ in mail content in wp_mail()
- Change Password notification text on mail
- On form submission how to send 2 email to different users
- Handle registrations in WordPress when user doesn’t have any email?
- WordPress comments email notification for authors
- Joining confirmation email
- How to setup SMTP for only one specific wp_mail()
- Sanitizing and validating email field
- Subscribe from another website to the same list [closed]
- WordPress E-mail Config
- WordPress email reply back to the original post author
- What can be wrong when automated backups stop being sent to email?
- Wp_new_user_notification doesn’t work
- Make WordPress use timezone for email Date header
- WordPress unable to send mail
- Not able to send links in email after setting header
- Stop the execution of foreach loop which extract data from array?
- wp_mail_from is ignored
- How to edit the WordPress e-mail that gives the user their password? [duplicate]
- What is the best way to send out thousands of emails from a WordPress site? [closed]
- Do action for only switch status for publish_post
- Generate Email if No Posts Within Time Period
- Interrupted cron script sending me hourly emails. Please help!
- Programming WordPress to Send an Email on Registration Form Submit?
- Does WordPress require port 25 for email?
- Send email notifications to a defined email address depending if a product in order has a specific TAG [closed]
- How do I disable the discussion notification emails to us when a comment is “approved” and when an adiministrator replies?
- Is there a plugin that will let you do actions by mail? [closed]
- What emails does wordpress send?
- Requiring wp-login.php sends headers automatically
- Changing email “From” address
- Changed my email. Locked out
- Add “Email Image” button with Hyperlink for individual images [closed]
- Block to accept and send email to specific domains
- Sending a password reset link
- How to prevent sending auto emails for specific actions in wordpress
- Receive no any emails from contact from 7 wordpress
- WordPress emails are not delivered if the recipient email address has a non-traditional domain extension
- Is it possible to use different from email in contact form 7 with different domain?
- Activation email to change admin address not being sent to Gsuite email account
- Send email with Content-Type text/plain
- How can I remove the product short description from the WooCommerce Mails?
- How to integerate WordPress Mail SMTP plugin to Report and Request custom page
- wp_mail() not sending emails with ajax
- changing notification emails from WordPress @mydomain.net to something else
- Emails sent from local wp webserver are beeing rejected from Siren?
- email explanation for newbies
- WordPress stops executing code after the require() method
- Exclude Current user email and send notification
- How to disable the “Your site has updated to WordPress x.y.z” admin email?
- User Registration – no Email required
- BCC email to subscribers
- Download Free Trial After Email Entered
- Duplicate notifications for new user registration
- Email notification
- Create WP account from an external email form submission?
- Can wordpress users check GMAIL (G Suite) inbox & send email from their membership account on WordPress? [closed]
- Look for one plugin which could send notification to any email when post publish
- What’s the simplest way to send WordPress posts to a Mailchimp list? [closed]
- Having Issue on Receiving Emails From @Gmail.com or @Yahoo. in WordPress Using PHP Mail Function
- Fighting Spam – What can I do as an: Email Administrator, Domain Owner, or User?
- How to add verification on email address change?
- Only Admin receives email
- Why is my custom email notification after purchase not sending?