{"id":1896569,"date":"2019-10-18T13:19:29","date_gmt":"2019-10-18T17:19:29","guid":{"rendered":"https:\/\/theeventscalendar.com\/knowledgebase\/auto-publish-events-submitted-by-logged-in-users-2\/"},"modified":"2026-04-20T19:46:36","modified_gmt":"2026-04-20T23:46:36","slug":"customize-event-submissions","status":"publish","type":"post","link":"https:\/\/theeventscalendar.com\/knowledgebase\/customize-event-submissions\/","title":{"rendered":"Customizing Community Events Submissions"},"content":{"rendered":"\n<p>The <a href=\"https:\/\/theeventscalendar.com\/products\/community\/\">Community Events<\/a> add-on gives visitors a frontend form for submitting events to your calendar. Once you have that form running, there are several points in the submission lifecycle where a little code can make things work more like you want them to: getting users to the form, handling what happens when they submit, and following up after an admin approves the event.<\/p>\n\n\n\n<p>This article collects five customizations covering that full lifecycle. Each one is independent \u2014 skip to whichever you need. Most are PHP snippets that go in your theme&#8217;s <code>functions.php<\/code> or the <a href=\"https:\/\/wordpress.org\/plugins\/code-snippets\/\">Code Snippets<\/a> plugin; see <a href=\"https:\/\/theeventscalendar.com\/knowledgebase\/best-practices-for-implementing-custom-code-snippets\/\">Using Custom Code Snippets<\/a> for the general how-to.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-adding-a-submit-event-button\">Adding a Submit Event Button<\/h2>\n\n\n\n<p>If you want visitors to easily find the Community Events submission form from your main calendar page, you can add a button or link using the built-in settings \u2014 no code required.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>In your WordPress Dashboard, navigate to <strong>Events \u2192 Settings \u2192 Display \u2192 Additional Content Settings<\/strong>.<\/li>\n\n\n\n<li>In the <strong>Add HTML before calendar<\/strong> field, insert the following HTML:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;div class=\"eventSubmitButton\"&gt;\n    &lt;a href=\"https:\/\/yourwebsite.com\/events\/community\/add\/\" class=\"tribe-common-c-btn\"&gt;Submit Event&lt;\/a&gt;\n&lt;\/div&gt;<\/code><\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>Replace <code>https:\/\/yourwebsite.com\/events\/community\/add\/<\/code> with the actual URL of your Community Events submission form.<\/li>\n\n\n\n<li>Scroll down and click <strong>Save Changes<\/strong>.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2025\/07\/image-2-edited-scaled.png\" alt=\"Submit Event button shown above the main calendar view\"\/><\/figure>\n\n\n\n<p>This displays a &#8220;Submit Event&#8221; button above your main calendar view. You can style the button further with custom CSS if needed. Community Events must be installed and active for the destination link to work.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-auto-categorizing-submissions\">Auto-Categorizing Submissions<\/h2>\n\n\n\n<p>You may want to automatically assign a specific category \u2014 say, &#8220;Community Event&#8221; \u2014 to every event submitted through the form, without letting users choose it themselves. By default, the plugin doesn&#8217;t have a setting for this, but a small filter handles it cleanly.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\nadd_filter( 'tec_events_community_alter_submission_mapping', function( $submission ) {\n    \/\/ IDs of categories you want to always add\n    $required_category_ids = &#91; 4 ];\n\n    $existing = &#91;];\n    if ( isset( $submission&#91;'tax_input']&#91;'tribe_events_cat'] ) ) {\n        $existing = (array) $submission&#91;'tax_input']&#91;'tribe_events_cat'];\n    }\n\n    $merged = array_values( array_unique( array_map( 'intval', array_merge( $existing, $required_category_ids ) ) ) );\n\n    $submission&#91;'tax_input']&#91;'tribe_events_cat'] = $merged;\n\n    return $submission;\n} );<\/code><\/pre>\n\n\n\n<p>Replace the <code>4<\/code> with the <strong>ID of your desired category<\/strong>. You can find the category ID by hovering over or editing the category in your WordPress dashboard \u2014 the ID appears in the URL.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2025\/09\/image.png\" alt=\"Finding a category ID in the WordPress dashboard\"\/><\/figure>\n\n\n\n<p>You may also want to <a href=\"https:\/\/theeventscalendar.com\/knowledgebase\/how-to-exclude-certain-categories-from-being-displayed-in-community-events-submission\/\">hide certain categories from the submission form<\/a> so users can&#8217;t pick them.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-auto-publishing-for-logged-in-users\">Auto-Publishing for Logged-In Users<\/h2>\n\n\n\n<p>Under <strong>Events \u2192 Settings \u2192 Community<\/strong>, you can set a default status for submitted events (Draft, Pending Review, or Published). But sometimes you want more nuance \u2014 for instance, auto-publishing events from trusted logged-in users while still holding anonymous submissions for review.<\/p>\n\n\n\n<p>This snippet auto-publishes any event submitted by a registered, logged-in user. Anything submitted by an anonymous user falls back to whatever your default status is set to.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\/**\n * Community Events (CE): If user is logged in, set post status to Published, else fallback to CE settings' default.\n *\n * Irrelevant if default post status in CE settings is Published or Anonymous Submissions are not allowed.\n *\/\nfunction set_community_events_publication_status( $option, $default, $optionName ) {\n    if (\n        ! class_exists( 'Tribe__Events__Community__Main' )\n        || 'defaultStatus' !== $optionName\n        || ! is_user_logged_in()\n    ) {\n        return $option;\n    }\n\n    return 'publish';\n}\n\nadd_filter( 'tribe_get_single_option', 'set_community_events_publication_status', 10, 3 );<\/code><\/pre>\n\n\n\n<p>This snippet has no effect if your default post status is already Published, or if anonymous submissions are disabled.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-redirecting-after-submission\">Redirecting After Submission<\/h2>\n\n\n\n<p>After a user submits an event, they&#8217;re taken to a default success page. You may want to redirect them somewhere more specific instead \u2014 a thank-you page, a pending-review explanation, or your calendar&#8217;s main view.<\/p>\n\n\n\n<p>[EDITOR: INSERT SNIPPET \u2014 The original article at \/redirect-to-a-different-url-after-event-submission\/ contains a &#8220;The Snippet&#8221; section with lead-in prose but the actual PHP code is not present in the rendered page. Based on the &#8220;For Developers&#8221; references at the bottom of the source article, the missing snippet likely hooks into <code>tribe_community_event_save_updated<\/code>, checks <code>tribe_is_event()<\/code>, and issues a redirect (possibly via <code>window.location.href<\/code> or <code>wp_safe_redirect<\/code>). Please retrieve the original code from the source article&#8217;s revision history or associated Gist and insert it here.]<\/p>\n\n\n\n<p>In the snippet, replace <code>\/sample-page\/<\/code> with the URL of the page you want users to be redirected to after submission.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-for-developers\">For Developers<\/h4>\n\n\n\n<p>Functions and references used by this customization:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>tribe_community_event_save_updated<\/code> \u2014 the action that fires after a Community Events submission is saved<\/li>\n\n\n\n<li><a href=\"https:\/\/docs.theeventscalendar.com\/reference\/functions\/tribe_is_event\/\"><code>tribe_is_event()<\/code><\/a> \u2014 check whether a given post is an event<\/li>\n\n\n\n<li><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Location\/href\"><code>window.location.href<\/code><\/a> \u2014 JavaScript location API, for client-side redirects<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-notifying-submitters-on-publish\">Notifying Submitters on Publish<\/h2>\n\n\n\n<p>By default, submitted events are saved as drafts until an administrator publishes them \u2014 but the original submitter isn&#8217;t notified when that happens. This snippet sends the submitter an email once their event goes live.<\/p>\n\n\n\n<p>Unlike the other snippets in this article, the original guidance for this one is to install it as a tiny single-file plugin rather than dropping it into <code>functions.php<\/code>. Either approach works \u2014 you can also use the Code Snippets plugin if you prefer. If you want to follow the file-based approach, create a new PHP file called <code>events-community-notify-submitter.php<\/code> in your <code>wp-content\/plugins\/<\/code> directory and paste the snippet in:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\/*\nPlugin Name: Tribe Snippet: Send email notification when the event is approved\nRequires PHP: 5.6\nVersion: 0.1\n *\/\n\nadd_action( 'transition_post_status', function ( $new_status, $old_status, $post ) {\n    \/\/ Early bail: We are looking for published posts only\n    if ( $new_status != 'publish' ) {\n        return;\n    }\n\n    \/\/ Early bail: Unexpected value\n    if ( ! $post instanceof WP_Post ) {\n        return;\n    }\n\n    \/\/ Early bail: We need the \"tribe\" function to be loaded\n    if ( ! function_exists( 'tribe' ) ) {\n        return;\n    }\n\n    $main = tribe( 'community.main' );\n\n    \/\/ Early bail: We could not get the desired class from the Container\n    if ( ! $main instanceof Tribe__Events__Community__Main ) {\n        return;\n    }\n\n    $default_status = $main-&gt;getOption( 'defaultStatus' );\n\n    \/\/ Early bail: Old status is not the default status\n    if ( $old_status != $default_status ) {\n        return;\n    }\n\n    \/\/ Early bail: We are just interested in Events\n    if ( $post-&gt;post_type != 'tribe_events' ) {\n        return;\n    }\n\n    $author = get_user_by( 'id', $post-&gt;post_author );\n\n    \/\/ Early bail: Author not available (eg: Anonymous submission)\n    if ( ! $author instanceof WP_User ) {\n        return;\n    }\n\n    $email = $author-&gt;user_email;\n\n    \/\/ Early bail: Invalid email\n    if ( ! filter_var( $email, FILTER_VALIDATE_EMAIL ) ) {\n        return;\n    }\n\n    $subject = sprintf( 'Congratulations! %s was published!', $post-&gt;post_title );\n    $message = sprintf( 'Congratulations, your event was published! Click &lt;a href=\"%s\"&gt;here&lt;\/a&gt; to view it!', esc_url( get_post_permalink( $post ) ) );\n\n    wp_mail(\n        $email,\n        esc_html__( $subject, 'tribe-events-community' ),\n        __( wp_kses_post_deep( $message ), 'tribe-events-community' ),\n        &#91; 'Content-Type: text\/html; charset=UTF-8' ]\n    );\n\n}, 10, 3 );<\/code><\/pre>\n\n\n\n<p>If you used the file-based approach, activate the plugin from the WordPress dashboard \u2014 it appears in the plugin list as &#8220;Tribe Snippet: Send email notification when the event is approved.&#8221;<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-frequently-asked-questions\">Frequently Asked Questions<\/h4>\n\n\n\n<p><strong>How do I customize the subject of the email?<\/strong><br>Edit the <code>$subject<\/code> line of the snippet.<\/p>\n\n\n\n<p><strong>How do I customize the body of the email?<\/strong><br>Edit the <code>$message<\/code> line of the snippet.<\/p>\n\n\n\n<p><strong>Does it send notifications for anonymous submissions?<\/strong><br>No. If you have &#8220;Allow anonymous submissions&#8221; enabled (<strong>Events \u2192 Settings \u2192 Community<\/strong>) and a user submits an event without being logged in, the snippet can&#8217;t identify an email address for that user and will not send a notification.<\/p>\n\n\n\n<p><strong>Does it send a notification if events are set to be published without review?<\/strong><br>No. If the &#8220;Default status for submitted events&#8221; (<strong>Events \u2192 Settings \u2192 Community<\/strong>) is set to &#8220;Published&#8221;, this snippet will not send any emails.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Community Events add-on gives visitors a frontend form for submitting events to your calendar. Once you have that form running, there are several points in the submission lifecycle where a little code can make things work more like you want them to: getting users to the form, handling what happens when they submit, and&#8230;<\/p>\n","protected":false},"author":84,"featured_media":1955565,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_kad_blocks_custom_css":"","_kad_blocks_head_custom_js":"","_kad_blocks_body_custom_js":"","_kad_blocks_footer_custom_js":"","_swpsp_post_exclude":false,"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"ep_exclude_from_search":false,"footnotes":""},"categories":[24,59,309],"tags":[],"stellar-product-taxonomy":[152],"class_list":["post-1896569","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-customizing","category-php-function-snippets","category-woocommerce","stellar-product-taxonomy-community-events"],"acf":[],"taxonomy_info":{"category":[{"value":24,"label":"Customizations"},{"value":59,"label":"PHP Functions &amp; Snippets"},{"value":309,"label":"WooCommerce"}],"stellar-product-taxonomy":[{"value":152,"label":"Community"}]},"featured_image_src_large":["https:\/\/images.theeventscalendar.com\/kb\/uploads\/2023\/02\/social-share-1024x538.png",1024,538,true],"author_info":{"display_name":"The Events Calendar Team","author_link":"https:\/\/theeventscalendar.com\/knowledgebase\/author\/the_events_calendar_team\/"},"comment_info":0,"category_info":[{"term_id":24,"name":"Customizations","slug":"customizing","term_group":0,"term_taxonomy_id":24,"taxonomy":"category","description":"","parent":0,"count":55,"filter":"raw","term_order":"0","cat_ID":24,"category_count":55,"category_description":"","cat_name":"Customizations","category_nicename":"customizing","category_parent":0},{"term_id":59,"name":"PHP Functions &amp; Snippets","slug":"php-function-snippets","term_group":0,"term_taxonomy_id":59,"taxonomy":"category","description":"","parent":24,"count":44,"filter":"raw","term_order":"0","cat_ID":59,"category_count":44,"category_description":"","cat_name":"PHP Functions &amp; Snippets","category_nicename":"php-function-snippets","category_parent":24},{"term_id":309,"name":"WooCommerce","slug":"woocommerce","term_group":0,"term_taxonomy_id":309,"taxonomy":"category","description":"","parent":46,"count":5,"filter":"raw","term_order":"0","cat_ID":309,"category_count":5,"category_description":"","cat_name":"WooCommerce","category_nicename":"woocommerce","category_parent":46}],"tag_info":false,"_links":{"self":[{"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1896569","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/users\/84"}],"replies":[{"embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/comments?post=1896569"}],"version-history":[{"count":3,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1896569\/revisions"}],"predecessor-version":[{"id":1969553,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1896569\/revisions\/1969553"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/media\/1955565"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/media?parent=1896569"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/categories?post=1896569"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/tags?post=1896569"},{"taxonomy":"stellar-product-taxonomy","embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/stellar-product-taxonomy?post=1896569"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}