Created
October 4, 2016 13:33
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This works just as expected but does anyone know how to make it trigger the admin notification emails again as well?