Custom notification for contributors when posts are scheduled

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 }

Comment notification not working

I do not see the $comment_ID variable having any value in your code. So try by changing the following code wp_notify_postauthor($comment_ID, $comment->comment_type); to wp_notify_postauthor($comment->comment_ID, $comment->comment_type); You can also remove $comment->comment_type as per codex

Different email notifications (about pending posts) to different users

add_action(‘future_to_pending’, ‘send_emails_on_new_event’); add_action(‘new_to_pending’, ‘send_emails_on_new_event’); add_action(‘draft_to_pending’, ‘send_emails_on_new_event’); add_action(‘auto-draft_to_pending’, ‘send_emails_on_new_event’); /** * Send emails on event publication * * @param WP_Post $post */ function send_emails_on_new_event($post) { $emails = “[email protected], [email protected]”; //If you want to send to site administrator, use $emails = get_option(‘admin_email’); $title = wp_strip_all_tags(get_the_title($post->ID)); $url = get_permalink($post->ID); $message = “Link to post: \n{$url}”; wp_mail($emails, “New post … Read more

I want to send push notification just after publish a new post

Wrap it in a function and hook it to transition_post_status: function wpse_18140_transition_post_status( $new, $old, $post ) { if ( $new === ‘publish’ && $new !== $old ) { // Your code here } } add_action( ‘transition_post_status’, ‘wpse_18140_transition_post_status’, 10, 3 ); This will run everytime a post is published, but not when you simply update the … Read more