• Resolved Hauzz

    (@hauzz)


    I would like to show visitors that the subscription for an event is not open when the start date for RSVP is in the future. Current;y I’m using this php:

    function get_rsvp_start_date($event_id) {
    // Haal de beginverkoopdatum van het ticket op
    $ticket_sales_start_date = get_post_meta($event_id, '_EventTicketStartDate', true);

    if (!$ticket_sales_start_date) {
    // Als de beginverkoopdatum van het ticket niet is ingesteld, geef een melding
    return '<p style="color: red; font-weight: bold;">?? Geen beginverkoopdatum voor het ticket gevonden.</p>';
    }

    // Vergelijk de huidige datum met de beginverkoopdatum
    $current_date = current_time('Y-m-d H:i:s');
    $ticket_sales_start_date_timestamp = strtotime($ticket_sales_start_date);
    $current_date_timestamp = strtotime($current_date);

    // Als de huidige datum vóór de beginverkoopdatum is
    if ($current_date_timestamp < $ticket_sales_start_date_timestamp) {
    return '<p style="color: red; font-weight: bold;">?? Registration is not yet open. Start sale date: ' . esc_html($ticket_sales_start_date) . '</p>';
    }

    // Als de inschrijving is geopend, geef een succesbericht
    return '<p style="color: green; font-weight: bold;">? RSVP is open!</p>';
    }

    // Shortcode om de RSVP startdatum te tonen
    add_shortcode('rsvp_startdatum', function() {
    $event_id = get_the_ID();
    return get_rsvp_start_date($event_id);
    });

    With this I get the message that the registration in not yet open.
    I guess I don’t have the correct meta key.
    Any help highly appreciated.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support tristan083

    (@tristan083)

    Hi @hauzz ,

    Thank you for reaching out.

    Just so you know, RSVPs are not meta key value pairs associated with an event when stored in the database. Instead, RSVPs are custom posts of type tribe_rsvp_tickets stored in the posts table. In that regard, RSVPs also have their own meta key value pairs (like posts) — see example of an RSVP post.

    I hope that makes sense. Please feel free to let us know how you go or if you have further questions/concerns.

    Thread Starter Hauzz

    (@hauzz)

    Thanks a lot, I got it working now. For those interested, below the code I use to show a message when the subscription date is in the future.

    // ===================== SHOW NOTIFICATION REGISTRATION DATE WHEN IT IS IN THE FUTURE ======================
    function debug_rsvp_list($event_id) {
    if (empty($event_id)) {
    return "?? No valid event ID specified.";
    }

    // Current date and time
    $current_time = current_time('timestamp');

    // Retrieve RSVP tickets linked to the event
    $args = array(
    'post_type' => 'tribe_rsvp_tickets',
    'meta_query' => array(
    array(
    'key' => '_tribe_rsvp_for_event',
    'value' => $event_id,
    'compare' => '='
    )
    )
    );

    $tickets = get_posts($args);
    $output = "";

    foreach ($tickets as $ticket) {
    $start_date = get_post_meta($ticket->ID, '_ticket_start_date', true);

    // Convert date to timestamp
    $start_timestamp = strtotime($start_date);

    // Check if the start date is in the future
    if ($start_timestamp > $current_time) {
    if (empty($output)) {
    $output .= "<div style='padding: 10px; border: 1px solid #ccc; background: #f9f9f9;'>";
    $output .= "?? <strong>Registration starts on: " . esc_html(date_i18n("d F Y", $start_timestamp)) . "</strong><br>";
    }
    }
    }

    // Only show a div if there are future tickets
    if (!empty($output)) {
    $output .= "</div>";
    return $output;
    }

    return ""; // No tickets in the future? Then we don't show anything.
    }

    function debug_rsvp_list_dynamic() {
    if (!is_singular('tribe_events')) {
    return "?? This is not an event page.";
    }

    $event_id = get_the_ID();
    error_log("?? Dynamic Event ID retrieved: " . $event_id);

    return debug_rsvp_list($event_id);
    }

    add_shortcode('debug_rsvp_list', 'debug_rsvp_list_dynamic');
    // ===================== END NOTIFICATION REGISTRATION DATE ======================

    You need of course a text block with shortcode [debug_rsvp_list] to show the message

    • This reply was modified 1 week, 1 day ago by Hauzz.
    Plugin Support tristan083

    (@tristan083)

    I’m glad to hear that, @hauzz !

    I’ll be closing this thread, but please do not hesitate to bump a new thread on our way if you have further questions/concerns. This is for us to track down topics/issues efficiently and for us to follow the WordPress Forum Guidelines.

    If you have some time to review, that would be amazing!
    https://www.ads-software.com/support/plugin/the-events-calendar/reviews/

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.