Support

Home Forums Event Espresso Premium Join Waiting List on custom post type

Join Waiting List on custom post type

Posted: November 5, 2013 at 11:03 pm


Jessica Grant

November 5, 2013 at 11:03 pm

I am using the custom post types option, so my event pages are being templated through “single-espresso_event.php” in my theme directory. I’m using those custom posts in the site instead of the standard espresso events pages (…/event-registration/?ee=5).

I would like to know if there is a way to add the “View Waiting List” button on these custom posts when the event has a waiting list and is sold out.

I am trying to modify code from “registration_page.php”:

...
$num_attendees = get_number_of_attendees_reg_limit($event_id, 'num_attendees');
if (($num_attendees >= $reg_limit) && ($allow_overflow == 'Y' && $overflow_event_id != 0)) {
...

The first conditional checking to see if the registration limit has been hit works. But I can’t get the second condition that checks for waiting list conditions to work. I’ve tried adding the following with the get_post_meta function, but the variables remain undefined:


$allow_overflow = get_post_meta($post->ID, 'allow_overflow', true);
$overflow_event_id = get_post_meta($post->ID, 'overflow_event_id', true);

Is there a way to define these variables correctly in single-espresso_event.php so they can be tested for? Is it not possible to do this with the custom post types? Is there a different approach I should be using?

I’ve managed to modify existing functions and shortcodes into my custom functions and shortcodes for all the other functionality I’ve needed, I just can’t get this one to work.

Thank you very much!


Dean

November 6, 2013 at 2:25 am

Hey,

So the data isn’t passed over for that sort of query, you will need to get a little in depth. We don’t normally add code blocks like this, but the current CPT system does lack in some areas.

Basically what I’ve done is called the core event via an SQL search. There might be other ways but this is the simplest in my opinion. After that I used one of the single-espresso_event.php’s code to get the max attendees, then it was just a matter of changing some variable names to match the sql output.

<?php

				global $wpdb;

				$cpt_event = $wpdb->get_results("SELECT * FROM " . EVENTS_DETAIL_TABLE . " WHERE id='" . $event_id . "'");

				$event_attendees_max = do_shortcode('[ATTENDEE_NUMBERS event_id="'.$event_id.'" type="reg_limit"]');

	            $num_attendees = get_number_of_attendees_reg_limit($event_id, 'num_attendees'); //Get the number of attendees

				if (($num_attendees >= $event_attendees_max) && ($cpt_event{'allow_overflow'} == 'Y' && $cpt_event['overlow_event_id'] != 0)) {

                ?>
                        <p id="register_link-<?php echo $cpt_event['overlow_event_id'] ?>" class="register-link-footer"><a class="a_register_link ui-button ui-button-big ui-priority-primary ui-state-default ui-state-hover ui-state-focus ui-corner-all" id="a_register_link-<?php echo $cpt_event['overlow_event_id'] ?>" href="<?php echo espresso_reg_url($cpt_event['overlow_event_id']); ?>" title="<?php echo stripslashes_deep($event_name) ?>"><?php _e('Join Waiting List', 'event_espresso'); ?></a></p>
                <?php
            	}

                ?>


Jessica Grant

November 6, 2013 at 12:28 pm

Hi Dean,

I understand this is above and beyond the normal scope of forum support, and I really appreciate your help with this. Thank you so very much, this is the last issue to get my event pages working as I’d like.

So I added the code you provided into the template and it’s not working as expected. I did a var_dump on $cpt[‘allow_overflow’] and $cpt[overflow_event_id] and both are returning NULL, so I suspect that’s the source of the problem. Any advice?

BTW, did you mean to type “overlow” in the code above? I changed it to “overflow” in all instances…


Josh

  • Support Staff

November 6, 2013 at 8:28 pm

Hi Jessica,

Are you looking to link to the waiting list’s event post? If so, here’s a gist that’s based on Dean’s above posted code that has a few tweaks:

Hope that helps!


Jessica Grant

November 7, 2013 at 3:40 pm

Thank you so much Josh, this works perfectly! I appreciate all your help making this possible.

The support post ‘Join Waiting List on custom post type’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso