Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lelandf/ec7d91f29bd282fe325bc6c02b5e7597 to your computer and use it in GitHub Desktop.
Save lelandf/ec7d91f29bd282fe325bc6c02b5e7597 to your computer and use it in GitHub Desktop.
[TEC] Add (required) to required custom fields on community edit event page.
add_action( 'wp_footer', function() {
// Stop if we're not on the community edit event page
if ( ! tribe_is_community_edit_event_page() ) {
return;
}
?>
<script>
// Function to add message to label
const addRequiredMessageToLabel = ( element ) => {
// Traverse to find the label
const label = element.closest( '.tribe-section-content-row' ).querySelector( 'label' );
// Add message to label
label.insertAdjacentHTML( 'beforeend', `<span class="tec-required-label">(required)</span>` );
};
// Select all required fields
const requiredFields = document.querySelectorAll( '.tribe-section-custom-fields .required' );
// Apply the function to each required field
requiredFields.forEach( addRequiredMessageToLabel );
</script>
<?php
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment