We were missing membership information in the recurring event posts
because the additional events are added to the database directly after
the main event post is created.
Events Manager tries to cater for main event post meta and copies it over
in EM_Event_Recurring_Post_Admin's save_post method which copies over all meta
from the original post.
We don't use meta for storing membership requirements so that doesn't help us.
Our pmpro_page_save hook never kicked in because the recurring event posts are added
as direct SQL queries in EM_Event::save_events().
This commit fixes by hooking into the em_event_save_events filter which is called at
the end of the save_events() function's run.
The filter returns the event, post_ids and event_ids, and so we are able to get the main post,
find its membership requirements (if any) from the pmpro_memberships_pages table,
and duplicate them as appropriate to each of the child events.
We were missing membership information in the recurring event posts because the additional events are added to the database directly after the main event post is created.
Events Manager tries to cater for main event post meta and copies it over in EM_Event_Recurring_Post_Admin's save_post method which copies over all meta from the original post. We don't use meta for storing membership requirements so that doesn't help us.
Our pmpro_page_save hook never kicked in because the recurring event posts are added as direct SQL queries in EM_Event::save_events().
This commit fixes by hooking into the em_event_save_events filter which is called at the end of the save_events() function's run. The filter returns the event, post_ids and event_ids, and so we are able to get the main post, find its membership requirements (if any) from the pmpro_memberships_pages table, and duplicate them as appropriate to each of the child events.