Skip to content

Instantly share code, notes, and snippets.

@sidharrell
Forked from Apina/EE Already Booked
Last active December 22, 2015 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sidharrell/5c94fa7a50ccfb9d93c8 to your computer and use it in GitHub Desktop.
Save sidharrell/5c94fa7a50ccfb9d93c8 to your computer and use it in GitHub Desktop.
<?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);
$booked = FALSE;
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>';
$booked = TRUE;
break;
}
}
}
if (!$booked) {
?>
<p class="event_form_submit" id="event_form_submit-<?php echo $event_id; ?>">
<input class="btn_event_form_submit ui-button ui-button-big ui-priority-primary ui-state-default ui-state-hover ui-state-focus ui-corner-all" id="event_form_field-<?php echo $event_id; ?>" type="submit" name="Submit" value="<?php _e('Submit', 'event_espresso'); ?>">
</p>
<?php
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment