Skip to content

Instantly share code, notes, and snippets.

@Apina
Last active December 16, 2015 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Apina/f11b5ce2db10f7b3bb93 to your computer and use it in GitHub Desktop.
Save Apina/f11b5ce2db10f7b3bb93 to your computer and use it in GitHub Desktop.
This is for EE3 only -- Creates a message on events for logged in users only, to tell them they have already booked the event. Should go in the event_list_display.php, but should be fine in the registration_page_display.php file as well. REQUIRES WP USER INTEGRATION to be active.
<?php
if ( is_user_logged_in() ) {
$current_user = wp_get_current_user();
//echo $current_user->ID;
$wpdb->get_results("SELECT id FROM ". EVENTS_MEMBER_REL_TABLE . " WHERE user_id = '" . $current_user->ID . "'");
if ($wpdb->num_rows > 0) {
$events = $wpdb->get_results("SELECT e.id event_id, e.event_name, e.event_code, e.start_date, e.event_desc, e.display_desc, a.id attendee_id, a.event_time start_time, a.payment_status, a.payment_date, a.amount_pd, u.user_id user_id, a.registration_id, a.lname, a.lname, a.price_option, a.event_time
FROM " . EVENTS_ATTENDEE_TABLE . " a
JOIN " . EVENTS_MEMBER_REL_TABLE . " u ON u.attendee_id = a.id
JOIN " . EVENTS_DETAIL_TABLE . " e ON e.id = u.event_id
WHERE u.user_id = '" . $current_user->ID . "'");
}
//var_dump($events);
$event_list_id = array();
foreach ($events as $eve) {
if ( $eve->user_id == $current_user->ID) {
$event_list_id[] = $eve->event_id;
}
}
}
//var_dump($event_list_id);
if($event_list_id == NULL) {} else {
foreach ($event_list_id as $id) {
if ($id == $event_id) {
echo '<p style="background-color:red; color:#fff; font-size:20px; text-align:center;">Hey you already booked this!</p>';
break;
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment