Okay
  Public Ticket #3651517
Reminders & RSVP
Closed

Comments

  •  1
    jesca started the conversation

    Two Questions: 

    1. I would like to create a reminder that automatically gets sent to everyone who has registered. Is that possible? Under reminder, I see you have to put email, can you just make it go to all emails that signed up?

    2. Also, does someone have to be logged in to your site to RSVP? I have tested and it give error "You must log in first" Can you allow RSVP without logging in?

  •  894
    Zhivko replied

    Hi,

    1. I wrote some time ago a code that sends a remind 2 days before the event to attendees:

    The code should be placed in your child-theme functions.php file.

    /**
     * Stachethemes Event Calendar 5.x mod
     * Automatically insert reminder for new attendees 2 days before event
     * @param (int) $result id of the newly created attendee
     * @return void
     * @since 5.0.7
     * 
     * @note: should be placed in the theme or child-theme (recommended) functions.php file
     */
    add_action('stec_after_attendee_create_item', function ($result) {
        
        if (false === is_numeric($result) || $result <= 0) {
            return;
        }
        $event_id       = get_post_meta($result, 'event_id', true);
        $event_title    = get_post_meta($result, 'event_title', true);
        $attendee_id    = get_post_meta($result, 'attendee_id', true);
        $attendee_email = get_post_meta($result, 'attendee_email', true);
        $event_date     = get_post_meta($result, 'event_date', true); // Y-m-d\TH:i
        $attend_date    = get_post_meta($result, 'date', true); // Y-m-d\TH:i
        $remind_date    = get_post_meta($result, 'remind_date', true); // Y-m-d\TH:i
        $attend_state   = get_post_meta($result, 'state', true);
        if (!$event_id || !$event_title || !$attendee_email || !$attend_date) {
            error_log('stec_after_attendee_create_item: missing data');
            return;
        }
        if ($attend_state !== 'attending') {
            return;
        }
        $event_timezone = \Stachethemes\Stec\Helpers::get_event_timezone($event_id);
        $remind_date_object = new \DateTime($attend_date, new \DateTimeZone($event_timezone));
        $remind_date_object->sub(new \DateInterval('P2D')); // two days before the event
        $remind_date_string = $remind_date_object->format('Y-m-d\TH:i');
        $title = implode('-', array(
            (0 !== $attendee_id ? $attendee_id : $attendee_email),
            $event_id,
            $event_date,
            $remind_date
        ));
        require_once(ABSPATH . 'wp-admin/includes/post.php'); // requred for post_exists to work
        $existing_post_id = post_exists($title, '', '', 'stec_remind');
        if ($existing_post_id !== 0 && $existing_post_id !== (int) $data['id']) {
            // remind already exists
            return;
        }
        
        $remind_author = $attendee_id ? $attendee_id : 0;
        $remind_post_data = array(
            'post_type'        => 'stec_remind',
            'post_status'      => 'publish',
            'comment_status'   => 'closed',
            'post_title'       => $title,
            'post_content'     => sprintf(
                esc_html__('You have an upcoming event tomorrow: %s', 'stec'),
                $event_title
            ), // you may want to edit this message
            'author'           => $remind_author,
            'meta_input'       => array(
                'author'            => $remind_author,
                'event_id'          => $event_id,
                'event_title'       => $event_title,
                'event_date'        => $attend_date,
                'user_id'           => $attendee_id,
                'remind_date'       => $remind_date_string,
                'email'             => $attendee_email,
                'tos'               => true,
                'read_permission'   => 'stec_private',
                'edit_permission'   => 'stec_private'
            )
        );
        $result = wp_insert_post($remind_post_data);
        if (is_wp_error($result)) {
            // log error
            error_log($result->get_error_message());
        }
    });
    

    2. Anonymous users can RSVP to the event.

    You must log in first to confirm your identity if you are using the email of a registered user.

    Most likely that's why you received this error.


    Stachethemes Developer