Change Required Fields on Community Event Submission Page

Home Forums Calendar Products Community Events Change Required Fields on Community Event Submission Page

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #107205
    Larry Martin
    Participant

    We want to require our contributors to either:
    – select a Saved Organizer, or
    – complete the Organizer Name, Phone and Email fields.

    On Jan. 13 you posted some code (http://bit.ly/1bPvdzc) that should enable us to require certain fields, but that won’t give us the either/or functionality. And staying with that code for a moment, we haven’t been able to get it to work. Here’s what we inserted in the functions.php file:

    /*—————————————————————–*/
    /* Add Required Fields to Community Events submission form in Events Calendar
    /*—————————————————————–*/
    add_filter(‘tribe_events_community_required_fields’, ‘add_required_fields’);
    function add_required_fields() {
    return array(
    ‘post_content’,
    ‘post_title’,
    ‘organizer[Organizer]’,
    ‘organizer[Email]’
    );
    }

    /*—————————————————————–*/
    /* Add Error Message (required fields) to Community Events submissions in Events Calendar
    /*—————————————————————–*/
    add_filter(‘tribe_events_community_submission_error_message’, ‘custom_error_message’);
    function custom_error_message() {
    return ‘<p>There was a problem saving your event. Please check to be sure you have filled in the following fields: </p>

    • Title
    • Description
    • Organizer Name
    • Organizer Email

    ‘;
    }

    This returns the error message. Unfortunately, it returns the error message even when we do complete the Organizer Name and Email fields. Alas. Maybe you can spot what we’ve got wrong.

    Our theme is Pagelines, btw, but the same thing happens in Twenty Thirteen.

    I’m afraid I’ve gone on too long, so, in brief, we want to always have Organizer Name and Email associated with an event. And (new request!), we’d like to have that information transmitted in the Email notification.

    Suggestions?

    #107235
    Barry
    Member

    Hi!

    Thanks for getting in touch – it’s always great to see people doing interesting things with our plugins 🙂

    Please remember that while we periodically make snippets and tutorials available it is often the case that they are intended to serve as blueprints for your own onward development rather than complete solutions and, indeed, something as specific as you are asking about isn’t generally something we can assist with.

    And staying with that code for a moment, we haven’t been able to get it to work. Here’s what we inserted in the functions.php file:

    ‘organizer[Organizer]’,
    ‘organizer[Email]’

    I’m not sure that Casey’s tutorial suggests you can specifically target specific indices of an array in that manner so you might need to take a different tack there.

    This returns the error message. Unfortunately, it returns the error message even when we do complete the Organizer Name and Email fields. Alas. Maybe you can spot what we’ve got wrong.

    So again it’s really a blueprint demonstrating how to add an error message to that view – so if you use it verbatim then, yes, it’s going to display the same message constantly. This is something where you would need to devise your own logic to control if an error message is displayed and what it should actually contain.

    Does that clarify things and is there anything you feel we could add to the tutorial to make aspects like this clearer?

    #107314
    Larry Martin
    Participant

    Barry, thanks for the response.

    Casey’s tutorial says “Just view the HTML source and find the correct <input> tag, and look for the ‘name’ attribute (screenshot) to specify in your array.” Here’s the source HTML for the Organizer section of the form:

    <!– Organizer –>
    <div class=”tribe-events-community-details eventForm bubble” id=”event_organizer”>
    <table class=”tribe-community-event-info” cellspacing=”0″ cellpadding=”0″>
    <tr>
    <td colspan=”2″ class=”tribe_sectionheader”>
    <h4>Event Organizer Details</h4>
    </td><!– .tribe_sectionheader –>
    </tr>
    <tr class=”” >
    <td style=”width:170px”><label for=”saved_organizer”>Use Saved Organizer:</label></td>
    <td><select class=”chosen organizer-dropdown” name=”organizer[OrganizerID]” id=”saved_organizer”><option value=”0″>Use New Organizer</option><optgroup label=”My Organizers”><option value=”6158″>Me</option><option value=”6122″>You</option></optgroup><optgroup label=”Available Organizers”><option value=”1273″>Somebody</option><option value=”5622″>Somebody Else</option><option value=”1523″>Etc.</option></optgroup></select></td>
    </tr>
    <tr class=”organizer”>
    <td>
    <label for=”OrganizerOrganizer” >
    Organizer Name:
    </label>
    </td>
    <td>
    <input type=”text” id=”OrganizerOrganizer” name=”organizer[Organizer]” size=”25″ value=”” />
    </td>
    </tr><!– .organizer –>
    <tr class=”organizer”>
    <td>
    <label for=”OrganizerPhone”>
    Phone:
    </label>
    </td>
    <td>
    <input type=”text” id=”OrganizerPhone” name=”organizer[Phone]” size=”25″ value=”” />
    </td>
    </tr><!– .organizer –>
    <tr class=”organizer”>
    <td>
    <label for=”OrganizerWebsite”>Website:</label>
    </td>
    <td>
    <input type=”text” id=”OrganizerWebsite” name=”organizer[Website]” size=”25″ value=”” />
    </td>
    </tr><!– .organizer –>
    <tr class=”organizer”>
    <td>
    <label for=”OrganizerEmail”>Email:</label>
    </td>
    <td>
    <input type=”text” id=”OrganizerEmail” name=”organizer[Email]” size=”25″ value=”” />
    </td>
    </tr><!– .organizer –>
    </table><!– #event_organizer –>
    </div>

    The HTML identifies the two terms – organizer[Organizer] and organizer[Email] – as the name attributes of the fields that we want to require. I copied them and plugged them into Casey’s array, which is what I thought the tutorial said do.

    What am I missing?

    Larry

    #107999
    Barry
    Member

    Hi Larry,

    I see what you mean – that’s definitely a little misleading and I’ll make a note for us to amend the tutorial accordingly. In general though, you will not be able to use any names that also include square brackets quite in this manner.

    That’s not to say you can’t or shouldn’t try to catch those and use them in your own required field check – just that you’d need to do a little extra work to make that happen.

    Apologies for any inconvenience on that one.

    #116768
    Barry
    Member

    It’s been a while so I’ll go ahead and close this thread. If you need further help though, for this or any other issue, please don’t hesitate to create new threads as needed. Thanks!

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Change Required Fields on Community Event Submission Page’ is closed to new replies.