Hi Stephen,
My next task arises out of scheduled emails. The email that is sent after an occurrence has happened is to prompt the user to tell the site whether he/she attended the occurrence or not. (My project is dealing mainly, if not solely with recurring events, and if someone signs up for an event, he/she is signing up for all future occurrences of that event.)
I figured that one way to store the information was in the booking meta. I’ve had a look through the //Save booking meta
section in booking-actions.php
(line 446), and I think I can see how information entered into the “meta” fields on the booking form ends up in the postmeta. However, I don’t want that meta field to show up on the booking form; rather the user needs to go to a page listing his/her past booked occurrences (which I’m reasonably confident I can do based on your guidance in your posts about bookees seing their bookings.
This page then needs to filter out occurrences where the user has already answered the question (presumably a simple query of the postmeta?), leaving a clickable list linking to individual occurrence pages (is this possible?), with an extra form attached with yes/no radio buttons and a submit. This would then write the yes/no to the postmeta and return the user to the list – if there’s anything still to answer. (Or, better, a list of booked past occurrences with radio buttons next to each and a submit button for all.)
Is this the best way to do it? If so, could you give me some pointers, please?
Thanks!
John
s2dd
Bookings are just a CPT of type eo_booking
, so the entire post API (specifically update_post_meta()
, get_post_meta()
is available to you. eo_get_booking_meta()
is specifically for ‘core’ meta / booking form as its essentially a wrapper for get_post_meta()
, but ensures the plug-in prefix is added to the meta key.
So yes, a WP_Query()
call to get bookings could exclude by meta value, and the approach you describe is the one I would use. I’d recommended writing it as a shortcode which you can then embed in a page. I’d also recommend that you prefix ‘hidden’ meta data with an underscore. This doesn’t really matter in this case, but its convention (such meta data wouldn’t appear in the a post’s custom fields, for example).
Stephen Harris
<p>Hi Stephen,</p>
<p>Thank you for that. I’m afraid I’ve got stuck on how occurrences work and how they are stored. All the events I’m dealing with are recurring events. I’ve just booked an event that started some time ago – so a number of occurrences have already happened – and I expected the _eo_booking_occurrence_id
in the postmeta to be a positive integer, rather than the zero that turned up.</p>
<p>I think I’ve probably misunderstood what _eo_booking_occurrence_id
does. Could you explain how I can dig up individual past occurrences that someone’s booked for, please?</p>
<p>Thanks, as ever,</p>
<p>John</p>
s2dd
If you’re booking as ‘series’ (e.g. you’re booking a place on an event – like with a course) then that ID is 0. If you’re booking individual dates, then it contains the occurrence ID. So to get events they (may) have already attended, you want to get the event ID and query past events for that event. (You can use the argument event_series
and set it to the event ID).
You can then add the occurrence ID to the booking meta key _attended
(a meta key can a have multiple values).
Hope that makes sense!
Stephen Harris
Hi Stephen,
Thank you for that. It makes sense, but I’m getting lost in the coding. This is possibly a cheeky request, but would you be prepared to write a plugin for it in return for a suitable donation?
Thanks!
John
-
This reply was modified 11 years, 8 months ago by Stephen Harris. Reason: Fixed formatting - bbpress' fault
s2dd
Hi John,
I’m available to do freelance work :). Send me an email via http://wp-event-organiser.com/contact/ and we can discuss it directly.
All the best,
Stephen
Stephen Harris