Support

Home Forums Event Espresso Premium Check event category on registration_page.php

Check event category on registration_page.php

Posted: February 12, 2013 at 5:56 pm


sheathe

February 12, 2013 at 5:56 pm

I have a customized version of registration_page.php and need to display different messaging when an event is full based on what category the event belongs to.

How do I use a category variable to check whether an event has been assigned to “My Category 1”?

Thanks for your help


Sidney Harrell

February 14, 2013 at 1:12 pm

This turned out to be harder than I thought it would at first glance, since the category(s) is not data that is pulled from the db about the event on the registration page. I had to write a custom db query to solve it:

$sql = "SELECT * FROM " . EVENTS_CATEGORY_REL_TABLE . " cr JOIN " . EVENTS_CATEGORY_TABLE . " c ON cr.cat_id = c.id WHERE cr.event_id = '" . $event_id . "' AND c.category_name = 'Category 1'";
$is_cat = $wpdb->get_row( $wpdb->prepare( $sql, NULL ), OBJECT);
if (!empty($is_cat)) { echo "is in Category 1";}

As you can see, you have to hard code the desired category name into the query, but you can then display different messages based on whether the event is or is not in that category. If you want to display different messages for each category, that’s a little different, but definitely doable.

The support post ‘Check event category on registration_page.php’ 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