/** * Process new event RSVPs * @version 2.0 */ function new_rsvp() { $rsvps = $this->rsvps; $new_rsvp = array(); // Clean each field individually if (!isset($_POST['attendance'])) { $error = 'You must select your expected attendance!'; } else { $new_rsvp['rsvp'] = $_POST['attendance']; } if ($this->req_role && empty($_POST['rsvp-role']) && $_POST['attendance'] != 'no') { $error = 'You must select your preferred role!'; } elseif ($this->req_role) { $new_rsvp['role'] = $_POST['rsvp-role']; } if (isset($_POST['rsvp-comment'])) { $new_rsvp['comment'] = sanitize_text_field($_POST['rsvp-comment']); } // If there are no errors, we can save the stuff if (!isset($error)) { // Update the postmeta $user_id = get_current_user_id(); $rsvps[$user_id] = $new_rsvp; update_post_meta($this->post_id, 'event_rsvps', $rsvps); bp_core_add_message('Thank you for responding!'); // Clear notifications on each group calendar foreach ($this->calendars as $calendar) { if (is_group_calendar($calendar->term_id)) { global $bp; $group_id = groups_get_id($calendar->slug); bp_notifications_delete_notifications_by_item_id($user_id, $group_id, $bp->groups->id, 'new_calendar_event', $this->post_id); } } // Redirect wp_redirect(get_the_permalink()); // Otherwise, throw the error message } else { bp_core_add_message($error, 'error'); } }
<?php /** * Apocrypha Theme Calendar Template * Andrew Clayton * Version 2.0 * 11-20-2014 */ // Get the current user $user_id = get_current_user_id(); // Get the requested calendar $calendar = get_queried_object(); $term_id = $calendar->term_id; $slug = $calendar->slug; // Does it belong to a specific group? $is_group = is_group_calendar($term_id); // Maybe use a different header or sidebar $group = $calendar->slug == 'entropy-rising' ? "er" : ""; ?> <?php get_header($group); ?> <div id="content" role="main"> <?php apoc_breadcrumbs(); ?> <header class="post-header <?php apoc_post_header_class('page');