Skip to content

Instantly share code, notes, and snippets.

@andrasguseo
Created November 3, 2023 20:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrasguseo/1912ff588af7fbc3f87452c01ec52c71 to your computer and use it in GitHub Desktop.
Save andrasguseo/1912ff588af7fbc3f87452c01ec52c71 to your computer and use it in GitHub Desktop.
CE > Set the post status to the "default status for submitted events" when a community event is edited
<?php
/**
* Set the post status to the "default status for submitted events" when a community event is edited.
*
* Plugins required: The Events Calendar, Community Events
* Author: Andras Guseo
* Created: November 3, 2023
*/
add_filter( 'tribe_events_event_update_args', 'tec_ce_pending_after_edit', 10, 3 );
/**
* Set the post status to the "default status for submitted events" when a community event is edited.
*
* @param array $args The fields we want saved.
* @param int $event_id The event ID we are modifying.
* @param WP_Post $post The event itself.
*
* @return array
*/
function tec_ce_pending_after_edit( $args, $event_id, $post ) {
// Bail, if Community Events is not active
if ( ! class_exists( 'Tribe__Events__Community__Main' ) ) {
return $args;
}
if (
! empty( $_POST['community-event'] )
&& $post->post_type == \Tribe__Events__Main::POSTTYPE
) {
$args['post_status'] = tribe( 'community.main' )->getOption( 'defaultStatus', 'pending' );
}
return $args;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment