Email attendee + attendee_name email tag

WordPress Event Management, Calendars & Registration Forums Request A Feature Email attendee + attendee_name email tag

This topic contains 5 replies, has 3 voices, and was last updated by  Alex Steer 8 years, 10 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #20439

    I am using Attendee Questions with EO pro 1.11.3. In attendee questions I ask for the attendee’s first and last name and their email.

    I am looking for a way to do two things:

    1. Email each attendee directly when the Bookee (also called the ticket
      holder i think) is emailed. Using a single ticket looking template.

    2. Add an email tag of %attendee_name% to the email template.

    James Cleaver
    #20485

    Hi James,

    This isn’t an altogether ‘neat’ solution as involves duplicating a lot of the code that is used to generate the e-mail for the bookee in order to send the same message (addressed differently) to each ticket holder. But here’s how its done:

    You use the eventorganiser_notify_confirmed_booking filter – this was intended so that the handling of booking confirmation e-mails could be over-ridden. In our case, we’re not going to over-ride it, but insert alongside – in short all ticket holders, the bookee and (if enabled) the site admin receive an e-mail.

    Inside our callback for that filter we shall retrieve the tickets for a booking, and for each ticket retrieve the email and name of the ticket holder (I’m assuming you’ve followed this article: http://wp-event-organiser.com/blog/tutorial/attendee-questions/). We’ll then replace the name placeholder tags with the name of the ticket holder, before letting eventorganiser_email_template_tags() do the rest of the placeholders. Finally we’ll send an e-mail to the ticket holder.

    add_filter( 'eventorganiser_notify_confirmed_booking', function( $send_default_email, $booking_id ) {
    
        //Get template
        $template = eventorganiser_pro_get_option( 'email_template' );
    
        // Get email details
        $from_name  = get_bloginfo( 'name' );
        $from_email = eo_get_admin_email( $booking_id );
    
        //Set message, subject, headers, attachment and template
        $raw_message =  eventorganiser_pro_get_option( 'email_tickets_message' );
    
        $subject     = apply_filters( 'eventorganiser_booking_confirmed_email_subject', __( 'Thank you for your booking', 'eventorganiserp' ), $booking_id );
        $subject     = wp_specialchars_decode( $subject, ENT_QUOTES );
    
        $headers = array(
            'from:' . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>",
            'reply-to:' . $from_email
        );
        $headers     = apply_filters( 'eventorganiser_booking_confirmed_email_headers', $headers, $booking_id );
    
        $attachments = apply_filters( 'eventorganiser_booking_confirmed_email_attachments', array(), $booking_id );
    
        $template    = apply_filters( 'eventorganiser_booking_confirmed_email_template', $template, $booking_id );
    
        //Now go through each ticket an e-mail the ticket holder    
        $tickets = eo_get_booking_tickets( $booking_id, false );
        foreach( $tickets as $ticket ) {
    
            // Ticket holder ('attendee') details
            $name       = eo_get_booking_ticket_meta( $ticket->booking_ticket_id, '_eo_booking_meta_attendee-name' );
            $first_name = $name[0];
            $last_name  = $name[1];
            $email      = eo_get_booking_ticket_meta( $ticket->booking_ticket_id, '_eo_booking_meta_attendee-email', true );
    
            //Replace name tags with name of the ticket holder
            $message = str_replace( array( '%first_name%', '%last_name%', '%display_name%' ), array( $first_name, $last_name, "$first_name $last_name" ), $raw_message );
    
            //Replace all other placeholders with appropriate information
            $message = eventorganiser_email_template_tags( $message, $booking_id, $template );
            $message = apply_filters( 'eventorganiser_booking_confirmed_email_body', wpautop( $message ), $booking_id );    
    
            //send!
            eventorganiser_mail( $email, $subject, $message, $headers, $attachments, $template );
    
        }
    
        return $send_default_email;
    }, 10, 2 );
    

    I hope that helps!

    Stephen Harris
    #20488

    Just added this code to the attendee questions code and it is working great. Thank you

    James Cleaver
    #21401

    Stephen,
    I just tried to answer one of my other posts with the code above however it didn’t send.
    Do you know if this still works?
    It just seems to stop all emails sending from the system, do you have any suggestions to why the above wouldn’t work for me?
    Thanks.

    Alex Steer
    #21429

    HI Alex,

    The above works fine for me. Have you tried using WP Mail Log (https://wordpress.org/plugins/wp-mail-logging/)?

    Stephen Harris
    #21431

    Hi Stephen,
    Sorry, I think I got it working – the testserver was being slow to send the mails out.
    However, I am still stuck on getting the attendee names to show by their corresponding ticket numbers.
    I see your suggestion to that in the other post.
    Thanks.

    Alex Steer
Viewing 6 posts - 1 through 6 (of 6 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.