Can’t set the venue field as required

Home Forums Calendar Products Community Events Can’t set the venue field as required

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #1260171
    Jean-Marie
    Participant

    Hello

    I want to set the venue field as required, so I set the following filters as described here : https://theeventscalendar.com/knowledgebase/required-fields-for-events-submission-form/

    function my_venue_community_required_fields($fields) {
        if(!is_array($fields)) {
            return $fields;
        }
        $fields[] = 'venue';
        $fields[] = 'organizer';
        return $fields;
    }
    add_filter('tribe_events_community_required_fields', my_venue_community_required_fields', 10, 1);
    
    function my_venue_community_required_venue_fields($fields) {
        if(!is_array($fields)) {
            return $fields;
        }
        $fields[] = 'Address';
        $fields[] = 'City';
        $fields[] = 'Zip';
        return $fields;
    }
    add_filter('tribe_events_community_required_venue_fields', 'my_venue_community_required_venue_fields', 10, 1);

    This works great for organizer, but I don’t get any error message when not filling the venue (by selecting an existing one or creating a new one).

    How can I fix this? Can you reproduce the issue? (I’m using the latest version of the community evens plugin / events plugin / events pro)

    Thanks for your assistance

    #1260415
    Victor
    Keymaster

    Hi Jean-Marie!

    Thanks for reaching out to us! 🙂

    Unfortunately, that code doesn’t work for venues or organizers anymore because there has been changes in the Community Events plugin and that code snippet worked for an older version of the plugin.

    However, it will work with “EventURL”, for example, but it won’t for venue or organizer.

    I did took notice of this and we are going to take it into account to find a way to make it work and will let you know about the solution in that same knowledgebase article.

    I’m sorry I can’t be of much help here, but we are limited in the support we can give for customizations like that.

    Let me know if any other questions.

    Best!

    Victor

    #1261814
    Jean-Marie
    Participant

    Hello Victor

    Thanks for your answer. Just to be clear, we’re not looking into any special customization, we just want to have the fields required as they supposed to be.

    Please notify me here when a solution will be provided.

    Thanks

    #1261977
    Victor
    Keymaster

    Hi Jean-Marie!

    Thanks for following up with this!

    Just to set expectations, those code snippets are just suggested as a starting point to accomplish certain customizations and we are limited in the support we can give for customizations like that, as stated in our Terms and Conditions.

    That said, we always try to help as much as we can, so rest assured we will have a look at this and try to come up with a solution, but it may take us a day or even more depending on our availability.

    Thanks for your patience and feel free to ask any other questions.

    Cheers!

    Victor

    #1265589
    Victor
    Keymaster

    Hi Jean-Marie!

    I’m sorry it took me so long to come back.

    I just wanted to follow up on this to let you know that we created a bug report for this issue and the team will address it for a future release.

    I will mark this thread as “Pending fix”. While we cannot tell an exact date on this, we will let you know as soon as the team fixes it. So please hang in there.

    Thanks for your patience!

    Victor

    #1279894
    Jean-Marie
    Participant

    Hi Victor

    Just to let you know: we tried the pre-release that you sent us, and the problem still occurs (it’s ok for organizer but not for venue field).

    Best regards

    #1280363
    Victor
    Keymaster

    Hi Jean-Marie!

    Thanks again for trying out the pre-release and letting us know about that.

    Feedback like this is always appreciated and many times helpful for devs to know, so I’ve just updated the bug report with your findings about the organizer now working.

    While I don’t have a date on this issue to be fixed, I can tell there has been some advancements on this and has already been reviewed by one of our devs.

    Best,
    Victor

    #1300146
    Victor
    Keymaster

    Hi Jean-Marie! 🙂

    I just wanted to let you know we think this issue is no longer a concern with our latest feature release of Community Events 4.5. We encourage you to update to the latest version and try it out.

    To find out more about the release -> https://theeventscalendar.com/release-community-events-4-5-the-events-calendar-4-5-4-pro-and-community-tickets/

    We hope this update makes your site much better!

    As always, don’t hesitate to open a new topic if anything comes up and we’d be happy to help! 🙂

    Best!
    Victor

    #1300332
    Jean-Marie
    Participant

    Hi Victor !

    Unfortunately the situation didn’t change at all for us and one of the required field – Venue details – is still not working… Same with our problem regarding the date.

    As a reminder, we noticed that if you set an event date and forgot one of the well working required fields, the page loads and a message appears to inform you you must fulfill the missing required field. But, when doing so, the event date is change back to current date. That is quite problematic as nothing informs you to check out your event’s date and thus, many people are un happy discovering afterward that they have to edit the event to change the date.

    Could you have a look at those issues?

    Thank you in advance.

    Best,

    #1300969
    Victor
    Keymaster

    Hi Jean-Marie!

    I’m sorry this issue is still present. Thanks for taking your time to let us know about it.

    I will take notice of this and add it to the bug report so it gets a second review.

    Regarding the date changing back to default upon failed submission, I could replicate myself and found a report about it. I will add this thread to it as well so we’ll let you know as soon as it is fixed.

    I apologise for these issues and we’d appreciate your patience.

    Best,
    Victor

    #1300975
    Victor
    Keymaster

    Hi there!

    Just wanted to give you a workaround for the required venue issue. You should put the following code snippet in your functions.php file:

    <?php
    /**
     * Require that a new or existing venue is specified when events are submitted via
     * the frontend submission form provided by Community Events.
     *
     * This is a temporary workaround for bug #76297.
     */
    
    function ce_submissions_require_venue( array $submission ) {
    	// Unhook self
    	remove_filter( 'tribe_events_community_sanitize_submission', 'ce_submissions_require_venue' );
    
    	// Gather submitted venue data
    	$venue_ids  = (array) Tribe__Utils__Array::get( $submission, array( 'Venue', 'VenueID' ), array() );
    	$new_venues = (array) Tribe__Utils__Array::get( $submission, array( 'Venue', 'Venue' ), array() );
    
    	// If there are signs of valid existing venues being specified, do nothing more
    	foreach ( $venue_ids as $possible_id ){
    		if ( absint( $possible_id ) ) {
    			return $submission;
    		}
    	}
    
    	// If there are signs of new venues being submitted, do nothing more
    	foreach ( $new_venues as $venue_name ) {
    		$venue_name = trim( $venue_name );
    
    		if ( ! empty( $venue_name ) ) {
    			return $submission;
    		}
    	}
    
    	// Force the venue check to run and fail
    	add_filter( 'tribe_events_community_required_fields', 'ce_submissions_add_venue_check' );
    	add_filter( 'tribe_events_community_required_venue_fields', 'ce_submissions_add_failure_field' );
    	add_filter( 'tribe_community_events_form_errors', 'ce_submissions_tidy_venue_error_message' );
    	return $submission;
    }
    
    function ce_submissions_add_venue_check( array $required_fields ) {
    	$required_fields[] = 'venue';
    	return $required_fields;
    }
    
    function ce_submissions_add_failure_field( array $required_fields ) {
    	$required_fields[] = '__unfindable';
    	return $required_fields;
    }
    
    function ce_submissions_tidy_venue_error_message( array $errors ) {
    	foreach ( $errors as $index => $error_message ) {
    		$message = $error_message['message'];
    
    		if ( false !== strpos( $message, '__unfindable' ) ) {
    			$errors[ $index ]['message'] = ce_submissions_strip_unfindable_error( $message );
    		}
    	}
    
    	return $errors;
    }
    
    function ce_submissions_strip_unfindable_error( $message ) {
    	$fragments = explode( '</p>', $message );
    
    	foreach ( $fragments as $index => $single_message ) {
    		if ( false !== strpos( $single_message, '__unfindable' ) ) {
    			unset( $fragments[ $index ] );
    		}
    	}
    
    	return join( '</p>', $fragments );
    }
    
    add_filter( 'tribe_events_community_sanitize_submission', 'ce_submissions_require_venue' );

    Please let us know if it works.

    Thanks,
    Victor

    #1312412
    Nico
    Member

    Hey,

    Just wanted to share with you that a new maintenance release (for the Week of 26th June 2017) is out, including a fix for this issue ?

    You should be able to use the snippet described in this article to make venue/organizers required.

    Find out more about this release → https://theeventscalendar.com/maintenance-release-week-26th-june-2017/

    Please update the plugins and let us know if the fix works for your site,
    Best,
    Nico

    #1324428
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

Viewing 13 posts - 1 through 13 (of 13 total)
  • The topic ‘Can’t set the venue field as required’ is closed to new replies.