Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elimn/f463ba3c9151cc7e17405c1ee8a39c1c to your computer and use it in GitHub Desktop.
Save elimn/f463ba3c9151cc7e17405c1ee8a39c1c to your computer and use it in GitHub Desktop.
MT | CE | Set status of Community Events to the default status after they have been edited
<?php
/**
* Sets the status of Community Events to the default status after they have been edited
*
* When you set Community submitted events to a status like "Pending Review" and a
* user submits a new event, it will be marked Pending Review and will not be visible
* until an admin publishes it. However if a user edits this event after it has been
* published, it will stay published. With this code it will instead go to Pending Review
* and will again be removed from public view until an admin republishes the event.
*/
class Tribe__Extension__Community_Events_Edit_Status {
function __construct() {
add_action( 'tribe_community_event_updated', array( $this, 'set_post_status' ) );
}
function set_post_status( $event_id ) {
$submitted_event_status = Tribe__Events__Community__Main::instance()->getOption( 'defaultStatus' );
$event_id = array(
'ID' => $event_id,
'post_status' => $submitted_event_status,
);
wp_update_post( $event_id );
}
}
new Tribe__Extension__Community_Events_Edit_Status();
@hirenshah
Copy link

This works just as expected but does anyone know how to make it trigger the admin notification emails again as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment