HIding unnamed/blank venues & organizers from choices

Home Forums Calendar Products Community Events HIding unnamed/blank venues & organizers from choices

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1253996
    William
    Participant

    Greetings! I was wondering if it would be possible to hide blank venues/organizer names from the choices when a user is filling out the community event submission form.

    I asked a similar question last year for the Filter Bar, which generated two options, both of which worked.

    https://theeventscalendar.com/support/forums/topic/hiding-unnamedblank-venues-organizers-from-filter-bar/

    To sum it up, because we use info from the venues and organizer fields in an exported version of this calendar for print, we regularly end up with no-name venues and organizers (e.g. meeting at a particular address for a hike, or contact info from an organizer who doesn’t want their name out there). As a result the dropdown menu for venue and organizer have a bunch of empty entries.

    Try as I might — with chrome inspector looking for elements for the jquery option and in the community files for a hook that might allow a version of option 2 to work — I wasn’t able to adapt these to the community page.

    #1254622
    Barry
    Member

    Hi William,

    Great question!

    Please keep in mind first of all that the degree of support we can offer for tasks requiring custom dev work tends to be rather limited. I certainly see the utility of your request, though, so would love to offer you some code that may – at the least – serve as a starting point you can build on as needed.

    function remove_empty_linked_posts_init() {
    	add_filter( 'tribe_events_linked_posts_query', 'remove_empty_linked_posts_setup' );
    }
    
    function remove_empty_linked_posts_setup( $passthru ) {
    	add_filter( 'the_posts', 'remove_empty_linked_posts' );
    	return $passthru;
    }
    
    function remove_empty_linked_posts( $posts ) {
    	$revised_post_list = array();
    	remove_filter( 'the_posts', 'remove_empty_linked_posts' );
    
    	foreach ( $posts as $candidate_post ) {
    		$post_title = trim( $candidate_post->post_title );
    
    		if ( ! empty( $post_title ) ) {
    			$revised_post_list[] = $candidate_post;
    		}
    	}
    
    	return $revised_post_list;
    }
    
    add_action( 'tribe_pre_get_template_part_community/modules/venue', 'remove_empty_linked_posts_init' );

    The above code, which you could add to a custom plugin (or, if you need to, your theme/child theme’s functions.php file) should successfully remove any venues from the Community Events submission form that have an empty post title.

    Does that help at all? Good luck with the project!

    #1254737
    William
    Participant

    Thanks! It worked.

    #1254825
    Barry
    Member

    Fantastic 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘HIding unnamed/blank venues & organizers from choices’ is closed to new replies.