Hide RSVP/Waitlist Until Tickets are sold out
-
This topic is related to this other one.
I was looking to implement the same solution but found it outdated, since i solved it and got it to work for me i thought to share it ??
Original topic was asking for a way to only show RSVP block when the event was sold out, this is useful when you need to use it as a waiting list.
@sjaure suggested to:
create a custom template for this template part: wp-content/plugins/event-tickets/src/views/v2/rsvp.php, then use the method tribe_events_count_available_tickets() to get the count of available tickets. If it is = 0 then you render the RSVP block, otherwise you return false.
This would have been a good solution if tickets and RSVP where counted separately, unfortunately RSVPs capacities are added to tickets capacities in the count, therefore when adding an RSVP the count will never be 0 unless the RSVP is at capacity too.
To achieve the result i instead added the following code after the IF statement on line 24:
DISCLAIMER: i am no professional, use the following code at your own risk, i do not assume any responsability for any issue that its use could create.
//we don't display anything if the event isn't sold out $event = tribe_get_event ($post_id); if (! $event->tickets->sold_out()) { return false; }
we gather the event object from the post id, then we check if the sold out value is not true, if that is the case we return false to displaying the rsvp block
i would suggest to also provide an override so that you can manually display the rsvp block even when the event is not sold out (you never know until you need it). You can do this with the custom fields of events calendar pro, if you have it, or with a custom post meta from wordpress by changing the code as follows:
/*SOLUTION WITH EVENTS CALENDAR PRO*/ //you have to create a custom checkbox and name it RSVPoverride for it to work or modify accordingly //retrieve event object $event = tribe_get_event ($post_id); //retrieve custom fields array $fields = tribe_get_custom_fields($event->ID); //we don't display anything if the event isn't sold out unless override is true if (! $event->tickets->sold_out() && empty( $fields['RSVPoverride'] )) { return false; }
or like this if you don’t have calendar pro
/*SOLUTION WITH WORDPRESS CUSTOM FIELDS*/ //you have to create a custom field and name it RSVPoverride for it to work or modify accordingly //write anything except 'false' in the custom field to override //retrieve event object $event = tribe_get_event ($post_id); //retrieve custom fields array $RSVPoverride = get_post_meta($post_id,'RSVPoverride',true); //we don't display anything if the event isn't sold out and the override is empty or false if (! $event->tickets->sold_out() && ! $RSVPoverride ) { return false; }
hope it helped ??
- The topic ‘Hide RSVP/Waitlist Until Tickets are sold out’ is closed to new replies.