Sean

Forum Replies Created

Viewing 15 posts - 76 through 90 (of 209 total)
  • Author
    Posts
  • in reply to: Default Country on Submit an Event form #1144953
    Sean
    Participant

    Hi Brook,

    I have done some template overrides before, but thank you for double checking!

    I tried changing the code you highlighted, but I’m still seeing the full list of countries when opening the Venue Country dropdown. Is there another place on the template that I should be changing to force the United States as the default (and only) option for the venue country dropdown?

    Thanks for your help,
    Karly

    in reply to: Default Country on Submit an Event form #1144151
    Sean
    Participant

    Thanks Brook and hope all is well. If this isn’t going to be released next week in the next release, it would be great if there’s a workaround to make the United States the default Country for the Venue on the Community Events Submit an Event form. Reason being is that we are stuck on an old version until this is fixed, simply because it would be a downgrade for the UX.

    Even if there’s a workaround to make the United States the default selection with it being the only option for the Venue Country (user can’t change it to another country) that would work fine since we only include USA-based events on our calendar anyways.

    Best regards,
    Karly

    in reply to: Organizer can’t be set as required field #1143964
    Sean
    Participant

    Hi Nico,

    Okay, this is working nicely now! I had forgotten to update to the latest version of the plugins after copying my production site over to a test site. With all of TEC plugins up to last week’s release, I am seeing the correct error message returned if the Organizer Name and/or Organizer Email are blank. Thank you so much for putting this snippet together for us!

    On a related note, I noticed on the latest versions, if the Venue is set to be required (either by adding ‘venue’ to the array or by setting each individual venue field to be required via a filter), no error message is returned if the fields are left blank (even though it says “(REQUIRED)” next to the Venue Details heading). Are you able to reproduce this issue on your end? If so, I’m happy to start another topic for it.

    Thanks and have a great day!
    Karly

    in reply to: Organizer can’t be set as required field #1143565
    Sean
    Participant

    Hi Nico,

    Hope you had a great weekend and thanks for your continued help. I just tested this and found that while the Organizer Name field was required and correctly returns the error message, the Organizer email address field is not required.

    Best regards,
    Karly

    in reply to: Organizer can’t be set as required field #1140070
    Sean
    Participant

    Thanks for putting this together Nico!

    I gave this a try on my staging site. Twentysixteen theme with your snippet added to the other related “required fields” snippets offered by Modern Tribe on this site (see below for the full code)

    In my testing, I found that while the message “Event Organizer is required” is displayed on the confirmation page beneath “Submit another event”, the form does not return an error message (and block the event from being submitted successfully) unless one of the other required fields is left blank (event name, website url, etc).

    Here’s the full code I have added to the default Twentysixteen theme, with all TEC plugins updated to the latest versions:

    *
     * -----------------------------------------------------
     *     TEC: Customize the List of Required Fields on
     *     the Community Events Submit an Event Form
     * -----------------------------------------------------
     *
     */
    add_filter( 'tribe_events_community_required_fields', 'my_community_required_fields', 10, 1 );
    
    function my_community_required_fields( $fields ) {
        $fields = array(
            'post_title',
    		'EventStartDate',
    		'EventStartHour',
    		'EventStartMinute',
    		'EventStartMeridian',
    		'EventURL',
    		'venue',
        );
    
        return $fields;
    
    }
    
    /*
     * -----------------------------------------------------
        Requiring the organizer email (or other "square bracketed"
        fields) can't be done using the above approach, but we can
        simply test within the $_POST superglobal directly.
    
        If a field hasn't been populated then we simply add a requirement
        using a field name we know doesn't exist, but can be used to form
        a meaningful error message (if the org email is missing the user
        will see "Organizer Email is required").
    
        You could take this a step further and additionally validate the
        email field to ensure it looks like a valid email address and
        provide an alternative error using the same approach.
     * -----------------------------------------------------
     *
     */
    
    add_filter( 'tribe_events_community_required_fields', 'tribe_community_required_fields_venue_city', 10, 1 );
    
    function tribe_community_required_fields_venue_city( $fields ) {
        if ( !empty($_POST['venue']["VenueID"]) )
            return $fields;
    
        if ( empty( $_POST['venue']['Address'] ) )
            $fields[] = 'Venue Address';
    
        if ( empty( $_POST['venue']['City'] ) )
            $fields[] = 'Venue City';
    
        if ( empty( $_POST['venue']['State'] ) )
            $fields[] = 'Venue State';
    
        if ( empty( $_POST['venue']['Zip'] ) )
            $fields[] = 'Venue Zip Code';
    
        return $fields;
    }
    
    // Customize Required Fields Error Message
    function ce_custom_error_msg( $errors ) {
    // Don't filter if it is an 'update' or other type of message
    if ( $errors[0]['type'] != 'error' ) return $errors;
    
    $existing_errors = '';
    $type = 'error';
    
    if ( is_array( $errors ) ) {
    $existing_errors = $errors[0]['message'];
    $type = $errors[0]['type'];
    }
    
    // Set overall message by appending a heading to the front
    if ( strpos($_SERVER['REQUEST_URI'], '/events/community/edit/') !== 0 ) {
    // You are not editing an event
    $errors[0] = array(
    'type' => $type,
    'message' => '<strong>The following fields are required:</strong>' . $existing_errors
    );
    }
    
    if ( strpos($_SERVER['REQUEST_URI'], '/events/community/edit/') === 0 ) {
    // You are editing an event
    $errors[0] = array(
    'type' => $type,
    'message' => '' . $existing_errors
    );
    }
    
    // User str_replace to choose a specific message to change
    $errors[0]['message'] = str_replace( 'Tax Input is required', 'Event Category is required', $errors[0]['message'] );
    $errors[0]['message'] = str_replace( 'Venue is required', 'Venue Name is required', $errors[0]['message'] );
    
    return $errors;
    }
    
    // Return custom error message
    add_filter( 'tribe_community_events_form_errors', 'ce_redirect_after_submit', 10, 1 );
    function ce_redirect_after_submit( $messages ) {
    if ( is_array( $messages ) && !empty( $messages ) ) {
    $messages = ce_custom_error_msg( $messages );
    $first_message = reset( $messages );
    if ( $first_message['type'] == 'update' ) {
    add_action( 'parse_request', 'tribe_redirect_after_community_submission', 11, 1 );
    }
    }
    return $messages;
    }
    
    /* Check for a valid Organizer (a saved organizer or a new one with name + email) */
    add_filter( 'tribe_community_events_form_errors', 'ce_custom_error_msgtwo' );
      
    function ce_custom_error_msgtwo( $errors ) {
     
        // bail if no post
        if ( empty( $_POST ) ) return $errors;
     
        // check for at least 1 valid organizer
        $valid_organizer = false;
     
        $cant_organizers = count ( $_POST['organizer']['OrganizerID'] );                
     
        for ( $i = 0; $i < $cant_organizers; $i++ ) {
     
            // saved organizer
            if ( !empty( $_POST['organizer']['OrganizerID'][$i] ) ) {
                $valid_organizer = true;
                break;
            }
     
            // organizer has name and email
            if ( !empty( $_POST['organizer']['Organizer'][$i] ) && !empty( $_POST['organizer']['Email'][$i] ) ) {
                $valid_organizer = true;
                break;
            }
     
        }
     
        if ( $valid_organizer ) return $errors;
          
         // add organizer error message
        $existing_errors = '';
        $type = 'error';
      
        if ( is_array( $errors ) ) {
            $existing_errors = $errors[0]['message'];
            $type = $errors[0]['type'];
        }
      
        $errors[0] = array(
            'type' => $type,
            'message' => $existing_errors . '<p>Event Organizer is required</p>' 
        );
      
        return $errors;
    }
    in reply to: Organizer can’t be set as required field #1138500
    Sean
    Participant

    Hi Nico,

    Thanks for seeing if there is a solution to this problem. It looks like Jesse is looking for the same requirements as I am: at least one Organizer is required (Organizer Name and Organizer Email Address are both required). If either field is left blank, an error message is returned (we’re already customizing the required fields and error messages as outlined in this TEC snippet).

    Thank you,
    Karly

    in reply to: Functions to Display only City and State for Venue #1134970
    Sean
    Participant

    Hi Hunter,

    Thanks for confirming! I tried it out and it appears to be working well.

    Hope you have a great weekend too!
    Karly

    Sean
    Participant

    Thanks Geoff. Appreciate the info on why this is still lingering. I know the next maintenance release just closed and thus a fix for this issue won’t make it into that. But hopefully the fix can be included in the following sprint/ maintenance release? We’re anxious to update to the latest versions and are just waiting for this to be resolved so we can go ahead and update.

    Have a good weekend,
    Karly

    Sean
    Participant

    Thanks Barry. Completely understand if the deadline to be included in the next released was missed. Looking forward to this being resolved in the next one. Appreciate you sharing the timeline as it does help to have an idea of when the fix should be available.

    Have a great weekend,
    Karly

    Sean
    Participant

    Thanks Barry. Hope it can make it into the next maintenance release.

    in reply to: Errors still reset the event date #1090352
    Sean
    Participant

    Hi Geoff,

    Thanks for following up on this and thanks to the dev team as well for this suggested modification to this snippet. I tested it out and…it works perfectly! So thank you very, very much again for helping get a resolution for this problem. As always, 5 star customer support all around!

    Kind regards,
    Karly

    Sean
    Participant

    This reply is private.

    Sean
    Participant

    Hi Geoff,

    I tried replacing

    if ( tribe_is_recurring_event() && ! is_singular( ‘tribe_events’ ) )

    with

    if ( tribe_is_showing_all() )

    but that unfortunately had no effect. Any others that I should try?

    Best regards,
    Karly

    in reply to: Errors still reset the event date #1088813
    Sean
    Participant

    Hi Geoff,

    I tried retesting and, like you, I was unable to reproduce this on a default theme with no customization’s. So that leaves both of us befuddled as to why it occurred on a “clean” installation before but isn’t occurring now! Needless to say this was a bit frustrating. But in any case, after much more testing on my own “custom” site, I found there appears to be an incompatibility with the latest release and this snippet:

    // Set edited Community Events to return to pending status after edit. This was also a fix for the default status of submitted events in a 3.X release
    add_filter( 'tribe_events_community_sanitize_submission', 'set_community_events_publication_status' );
    function set_community_events_publication_status( $submission ) {
    $submission['post_status'] = 'pending';
    return $submission;
    }

    With that in functions.php, the date is reset after errors are returned. Removing it allows the date to correctly be retained after an error is returned. This was surprising, as I can’t think of any reason why the status of the post would be effecting the date fields (especially as no other fields are being reset). Any ideas why this is happening and how it could be resolved?

    Thanks and have a good night,
    Karly

    in reply to: Errors still reset the event date #1087906
    Sean
    Participant

    I tried re-saving the settings and the issue persists.

    To confirm, this has been reproduced on the Twentyfifteen theme with only Modern Tribe plugins activated.

Viewing 15 posts - 76 through 90 (of 209 total)