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”?
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.
Viewing 1 reply thread
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.
Support forum for Event Espresso 3 and Event Espresso 4.