Email Alert for Events Awaiting Review
Emails your events editor whenever an event is submitted for review (for example through Community Events or by a contributor), with a direct link to approve it.
Opens WPIDE on
Code
$wpide_editor_email = get_option( 'admin_email' ); // Recipient.
add_action( 'transition_post_status', function ( $new, $old, $post ) use ( $wpide_editor_email ) {
if ( 'tribe_events' !== $post->post_type || 'pending' !== $new || 'pending' === $old ) {
return;
}
$start = get_post_meta( $post->ID, '_EventStartDate', true );
wp_mail(
$wpide_editor_email,
sprintf( '[%s] Event awaiting review: %s', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ), $post->post_title ),
sprintf(
"A new event is waiting for review.\n\nTitle: %1\$s\nStarts: %2\$s\nReview: %3\$s\n",
$post->post_title,
$start ? $start : 'not set',
admin_url( 'post.php?post=' . $post->ID . '&action=edit' )
)
);
}, 10, 3 );
Notes
Set $wpide_editor_email; it defaults to the site admin email.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.