• Resolved Miguel Peixe

    (@miguelpeixe)


    Hello,

    For a while now I’ve been managing to work Events-Manager with custom taxonomies, I can tell you it have been not an easy work…

    Now I was testing recurring events (that I had to declare my custom taxonomy to work with the post type ‘event-recurring’. It saves the custom taxonomies in the event-recurring post, but not in the events they created for each day, so it doesn’t really helps me.

    Hope you guys have some fix for that soon
    Thanks

    https://www.ads-software.com/extend/plugins/events-manager/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter Miguel Peixe

    (@miguelpeixe)

    Fix update:

    looking up the em_event_save_events filter I came up with the solution for that, just place it in your functions file changing the custom taxonomy to your own:

    // saving recurring events
    add_filter('em_event_save_events', 'save_recurring_events_custom_tax', 100, 3);
    function save_recurring_events_custom_tax($bool, $post, $events_id) {
    	$formats = get_the_terms( $post->post_id, 'format');
    	$formats_slugs = array();
    	if( is_array($formats) ) {
    		foreach($formats as $format) {
    			if( !empty($format->slug) ) $formats_slugs[] = $format->slug;
    		}
    	}
    	$formats_slugs_count = count($formats_slugs);
     	foreach($events_id as $event_id){
    		if( $formats_slugs_count > 0 ){
     			$event = em_get_event($event_id);
    			wp_set_object_terms($event->post_id, $formats_slugs, 'format');
    		}
     	}
    	return true;
    }

    How did you use custom taxonomies with events?
    I have another taxonomy plugin that detects Events and Recurring Events as Custom Post Types so I can assign taxonomies to them. The meta-boxes show up on the Edit Event screen. But how do I retrieve that information?

    Thread Starter Miguel Peixe

    (@miguelpeixe)

    Blackgossbo, the taxonomy detects and shows up the metabox for term assignment but it doesn’t save. The solution is to use the hook provided by the Events Manager plugin as in my previous comment.

    The filter em_event_save_events allows you to save custom data for the event. That’s what I’m using to save the post with the term assignment.

    In the example above my taxonomy is “format”, you can change it to your custom taxonomy and it should work with regular event and recurring events.

    Cool, thanx! I’ll try it. Were you able to use the taxonomy in a placeholder? How do I retrieve it?

    That didn’t work. Apparently, the latest version uses events and recurring events as custom types.
    Event Categories and other custom taxonomies are stored the same way in the database.
    To add a placeholder based on a custom taxonomy called “dress-code”. I got it to work! Thanks for your help anyway.

    function my_em_custom_placeholders($replace, $EM_Event, $result){
    	global $wp_query, $wp_rewrite;
    	switch( $result ){
    		case '#_DRESSCODE':
    			$replace = 'none';
    			$dresscodes = get_the_terms($EM_Event->post_id, 'dress-code');
    			if( is_array($dresscodes) && count($dresscodes) > 0 ){
    				$dresscodes_list = array();
    				foreach($dresscodes as $dresscode){
    					$link = get_term_link($dresscode->slug, 'dress-code');
    					if ( is_wp_error($link) ) $link = '';
    					$dresscodes_list[] = '<a href="'. $link .'">'. $dresscode->name .'</a>';
    				}
    				$replace = implode(', ', $dresscodes_list);
    			}
    
    			break;
    	}
    	return $replace;
    }
    add_filter('em_event_output_placeholder','my_em_custom_placeholders',1,3);

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: Events Manager] Recurring events not saving custom taxonomy’ is closed to new replies.