• Resolved DCuserName

    (@dcusername)


    This is a little obscure, but hoping someone might have ideas. I’ve defined a custom taxonomy shared by both event and recurring event post types. I can see it on both, and set it on either. If I set it on a recurring post though, the change isn’t replicated on the individual event post instances. Anyone know why that might be? I also tried using the WordPress save_post hook to update event posts with a taxonomy change, thinking that it should be triggered when the recurring post is saved, since the individual events must be updated after a recurring post edit, but no luck.

    Bit of a long shot in case anyone else has gone down this road before!

    Thanks,
    David

Viewing 7 replies - 1 through 7 (of 7 total)
  • From experience into hooking into EM I can tell you that the WP save_post hook does very, very, very little for the EM tables ??

    You could try hooking into the ’em_event_save_pre’ action. That will parse the $EM_Event through it before writing to the database.

    I have a similar issue. I’ve defined new post types (like a business) using the Toolset plugin. Their features let you define relationships, so I can associate the events for a business with that business. The problem is that the recurrence gets the relationship and not the individual event. I’ve already made some modifications to allow display of a recurring event and added my own placeholder for recurrence pattern (#_RECURRENCEPATTERN). This works great for the display of the business, but when I am looking at a particular instance of the recurrence, I can’t see the relationship.

    My wish/thought (I just discovered today and won’t work on it until January) is from the event instance to tap into the information from the recurring event post. I wish there was a placeholder or a way to access that like in an event we can access address & other details on the associated location.

    Other applications of this would be on an event instance to display other upcoming events in the recurrence.

    Just a couple of my thoughts on a similar issue that might give you a different way to appraoch.

    Thread Starter DCuserName

    (@dcusername)

    Patrick, I must have missed your reply earlier, I’ll try the em_event_save_pre action, that sounds promising! I managed to nerf the whose database last night with one of my experiments, ha, thank various deities for backups….

    Thread Starter DCuserName

    (@dcusername)

    a2withkids, thanks for that. I think I actually did find a custom field in the individual event with the recurring event ID, I’ll post it here when I find it, or just do a dump of the post meta and you should see it. The problem I had was that EM uses it’s own IDs for events and Recurring events, which is different from the post ID, so you have to write a little function to look up the post ID in most cases. Probably what’s needed is just some small helper functions for this kind of thing. This is my first time working with the plugin so I’m sortof stumbling on each new quirk, worth it though I think, it’s overall a much more robust plugin than others that I looked at.

    Just wondering…
    Why don’t you simply use the #_ATT{my_field}? That is in essence a custom field, especially for Events Manager Events.

    What that shortcode actually does is:
    echo get_post_meta( get_the_ID(), 'my_field');

    You define the #_ATT{key} in Events -> Settings -> General Options -> Event Attributes. Then they will appear in the Attributes metabox on the Event Edit Page.

    You can see it’s an actual meta field, in the wp_postmeta table, where all meta fields are saved ??

    You can also make then into dropdown selection boxes.
    https://wp-events-plugin.com/documentation/event-attributes/

    Thread Starter DCuserName

    (@dcusername)

    Hmm, I probably don’t understand attributes yet. I started down the road of a taxonomy because it will let me filter results later in the shortcode. I’m building a local business directory (sortof) in conjunction with the calendar, so I’ve created a dropdown custom field via the Advanced Custom Fields plugin to appear on both Events and Recurring Events. The ACF field allows for choosing any business in the directory (a custom post type), and saves as the post ID, and that value does seem to save to individual event instances when saving a recurring event. The business chosen in that field is the “owner” of the event, which I use for selectively displaying events on business listing pages. If I could, I would use that custom field to filter the EM results, but the closest option I could find ( https://wp-events-plugin.com/documentation/event-search-attributes/ ) in EM is to filter based on a taxonomy — Sorry for the long backstory, but are you saying that defining an Attribute would let me filter events in the EM shortcode based on that attribute? The only problem I see is that I need to keep the ACF dropdown field so that the workflow of choosing a business is easy.

    Thread Starter DCuserName

    (@dcusername)

    Okay, this seems to work, in case anyone has need of code to do additional updates to individual recurring event instances after the recurring event is saved.

    add_filter('em_event_save_events', 'my_em_styles_event_save_events', 10, 3);
    	function my_em_styles_event_save_events($result, $EM_Event, $event_ids) {
        if ($result) {
    			if (is_array($event_ids)) {
    				foreach ($event_ids as $event_post_id=>$event_id) {
    					// Do updates to individual post, using $event_post_id
    				}
    			}
    		}
    	}
    }

    Patrick’s suggestion about em_event_save_pre was key, except that I needed a hook for after the post was saved. I found a reference here:

    https://wp-events-plugin.com/tutorials/saving-custom-event-information/

    $event_ids is an array of recurring event individual events, where the key is the post ID and the value is EM’s event ID. So you can just loop through and do post updates using the array element KEY.

    Phew. Thanks all for the ideas and help!
    David

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Replicate recurring post custom taxonomy on individual events?’ is closed to new replies.