Halloween Sale 15% off Ends in See the plans
PHP

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.

Don’t have WPIDE yet? Install it on your site

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

  1. Install WPIDE on your WordPress site (it is free) and open Code Snippets.
  2. Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
  3. It is added inactive: review the code and settings, then switch it on.

Have a snippet worth sharing?

Publish it to the library from WPIDE or right here. Sign in with any WordPress site that runs WPIDE, free or Pro. Public snippets are reviewed by the WPIDE team before they appear.

Which site should get this snippet?

Enter the address of your WordPress site. WPIDE opens there in a new tab with the snippet ready to review and save.

Remembered in this browser only, so you are asked once.

Report this snippet

Tell the WPIDE team what is wrong: broken code, something harmful, spam or copied work.