Created
November 3, 2023 20:56
-
-
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
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 | |
/** | |
* 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