How to require information in additional fields.

Home Forums Calendar Products Community Events How to require information in additional fields.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #70062
    brooklyneagle
    Participant

    I’m using Community Events without requiring login but wish to capture the person’s name, phone number and email address for future contact from our sales department. I’ve created three additional fields for this information. 1. How do I make these additional fields required from users? 2. How do I make these fields NOT display on the calendar? 3. How do I customize the form to place these fields at the beginning of the form?

    #70136
    Casey
    Participant

    Brookylneagle,
    You could make the fields required by adding some custom JavaScript to the form. You can add Javascript to the page by adding the following code to your theme’s functions.php file: https://gist.github.com/ckpicker/6903757

    In order to have your custom fields display first, you’ll have to perform a template override on the edit-event.php file. Create the following folder structure in your theme directory: ‘tribe-events/community’ and then copy edit-event.php from ‘/wp-content/plugins/the-events-calendar-community-events/views/’. Once you’ve done that, you can modify edit-event.php and find this code on line 63:

    tribe_get_template_part('modules/custom');
    

    and move it to line 24 so it’s above this code:

    do_action( 'tribe_events_community_before_the_event_title' );
    

    Finally, in order to hide those fields from displaying on the Calendar, just paste the following code into your theme’s functions.php file: https://gist.github.com/ckpicker/6904714

    This code will hide all custom fields for an event. If you’d only like to hide certain fields, then you’ll have to interact with the Meta Walker. Take a look at Part III on this tutorial to point you in the right direction: https://theeventscalendar.com/the-events-calendar-templates-an-overview-in-three-parts/

    Hope that helps!

    #70325
    brooklyneagle
    Participant

    Great, all of your suggestions work perfectly.

    For the custom javascript for required fields, the additional fields that need to be required are labeled with the slugs your-name, your-email, you-phone-number. Do you have specific code that will make these items required?

    #70481
    Casey
    Participant

    No, but something similar to this would probably work:


    if(jQuery('input[name="field_name"]').val() == "") {
    alert("Error Message");
    return false;
    }

    I would suggest looking around online for some helpful tutorials (like this one) that can get you the rest of the way there.

    Hope that helps!

    #981839
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘How to require information in additional fields.’ is closed to new replies.