//https://codex.wordpress.org/Post_Status_Transitions //send email to admin after user create new deal from frontend form. 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'); add_action('pending_to_publish', 'send_emails_on_deal_publish'); /** * Send emails on event publication * * @param WP_Post $post */ function send_emails_on_new_event($post) { $emails = "customemail@email.com"; //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_edit_post_link( $post->ID, $context ); $message = "New Deal Created on Site Name!. Review and Publish. \n Link to post: \n{$url}"; if(get_post_type($post->ID) === 'deal') //post, page, attachment or whatever other CPT you may have { wp_mail($emails, "New Deal Created on Site Name: {$title}", $message); } } function send_emails_on_deal_publish($post) { $author_id=$post->post_author; $emails = get_the_author_meta( 'user_email' , $author_id ); ; //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 = "Your Deal is Live.\n Check Deal: \n{$url}"; if(get_post_type($post->ID) === 'deal') //post, page, attachment or whatever other CPT you may have { wp_mail($emails, "Your Deal on Site Name is Live: {$title}", $message); } }