Skip to content

Instantly share code, notes, and snippets.

@cliffordp
Last active November 4, 2019 23:02
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 cliffordp/9b4dff692829ce5d9ddd46d849689dbb to your computer and use it in GitHub Desktop.
Save cliffordp/9b4dff692829ce5d9ddd46d849689dbb to your computer and use it in GitHub Desktop.
Community Events (CE): If user is logged in, set post status to Published, else fallback to CE settings' default.
<?php
/**
* Community Events (CE): If user is logged in, set post status to Published, else fallback to CE settings' default.
*
* Irrelevant if default post status in CE settings is Published or Anonymous Submissions are not allowed.
*
* @link https://support.theeventscalendar.com/420384-Auto-publish-events-submitted-by-logged-in-users Relevant help article.
* @link https://gist.github.com/cliffordp/9b4dff692829ce5d9ddd46d849689dbb This snippet.
*
* @param mixed $option The option value.
* @param mixed $default The fallback value.
* @param mixed $optionName The name of the option.
*
* @return mixed
*/
function set_community_events_publication_status( $option, $default, $optionName ) {
if (
! class_exists( 'Tribe__Events__Community__Main' )
|| 'defaultStatus' !== $optionName
|| ! is_user_logged_in()
) {
return $option;
}
return 'publish';
}
add_filter( 'tribe_get_single_option', 'set_community_events_publication_status', 10, 3 );
@aacosta6788
Copy link

aacosta6788 commented Nov 4, 2019

This snippet caused my site to break as it loops it over and over again on page load. I copied as is so not sure what went wrong.

@cliffordp
Copy link
Author

@aacosta6788 please post your question to https://support.theeventscalendar.com/ as support is not provided here

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