Tickets email needs to send to customer and other email addresses.

Home Forums Ticket Products Event Tickets Plus Tickets email needs to send to customer and other email addresses.

Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • #1407921
    Ryan
    Participant

    Hello,

    I tried following instructions from this post but did not get the BCC for ticket emails to work. https://theeventscalendar.com/support/forums/topic/email-tickets-to-customer-and-another-email-address/

    The code I added is below. I did change the emails when I implemented on my site. I left out the line get_option( ‘admin_email’ ), because I don’t need it to go to the site admin. Thanks for your help.

    /**
      * BCC multiple email addresses, including the site admin email address, on all Event Tickets' RSVP ticket emails so they get a copy of it too
      *
      * From https://gist.github.com/cliffordp/c4fb2ea8fb5ca44973ff06e6facc9742
      * A fork of https://gist.github.com/cliffordp/4f06f95dbff364242cf54a3b5271b182
      * For https://theeventscalendar.com/support/forums/topic/event-tickets-free-not-plus-rsvp-notifications/#post-1272819
      *
      * @link https://developer.wordpress.org/reference/functions/wp_mail/#comment-349
      */
    function cliff_et_rsvp_bcc_admin_and_more_ticket() {
    	$bccs = array(
    	  '[email protected]', // edit or delete this line
     	  '[email protected]', // edit or delete this line
    	);
    	
    	// set Headers to Event Tickets' default
    	$headers = array( 'Content-type: text/html' );
    	
    	// add each BCC email if it's a valid email address
    	foreach ( $bccs as $bcc ) {
    		$bcc = sanitize_email( $bcc );
    		
    		if ( is_email( $bcc ) ) {
    			$headers[] = sprintf( 'Bcc: %s', $bcc );
    		}
    	}
    	
    	return $headers;
    }
    add_filter( 'tribe_rsvp_email_headers', 'cliff_et_rsvp_bcc_admin_and_more_ticket' );
    #1407930
    Ryan
    Participant

    Also, I did test the code with the get_option( ‘admin_email’ ) line as instructed in the other thread and it still did not work.

    #1408621
    Andras
    Keymaster

    Hi Ryan,

    Thanks for reaching out! Sorry to hear that snippet doesn’t want to work for your site.

    Here is a more simple version of that snippet, could you give this one a go and check if this works?

    https://gist.github.com/andrasguseo/3fd11aa0eea00f23b4444848b97ecf35

    Let me know.

    Cheers,
    Andras

    #1416309
    Ryan
    Participant

    Hello,

    That code did not work either. My current child functions.php file is below in case you see any errors or conflicts.

    Thanks,
    Ryan

    `
    have_posts() ) {
    if ( $wp_query->get( ‘paged’ ) > 1 ) {
    // if we’re on page 1, show the selected tribe-bar-date as the first date in the range
    $first_event_date = tribe_get_start_date( $wp_query->posts[0], false );
    } else {
    //otherwise show the start date of the first event in the results
    $first_event_date = tribe_event_format_date( $_REQUEST[‘tribe-bar-date’], false );
    }
    $last_event_date = tribe_get_end_date( $wp_query->posts[ count( $wp_query->posts ) – 1 ], false );
    $title = sprintf( $title_range, $first_event_date, $last_event_date );
    } elseif ( tribe_is_past() ) {
    $title = $title_past;
    }
    // Month view title
    if ( tribe_is_month() ) {
    $title = sprintf(
    $title_month,
    date_i18n( tribe_get_option( ‘monthAndYearFormat’, ‘F Y’ ), strtotime( tribe_get_month_view_date() ) )
    );
    }
    // Day view title
    if ( tribe_is_day() ) {
    $title = sprintf(
    $title_day,
    date_i18n( tribe_get_date_format( true ), strtotime( $wp_query->get( ‘start_date’ ) ) )
    );
    }
    // All recurrences of an event
    if ( function_exists(‘tribe_is_showing_all’) && tribe_is_showing_all() ) {
    $title = sprintf( $title_all, get_the_title() );
    }
    // Week view title
    if ( function_exists(‘tribe_is_week’) && tribe_is_week() ) {
    $title = sprintf(
    $title_week,
    date_i18n( $date_format, strtotime( tribe_get_first_week_day( $wp_query->get( ‘start_date’ ) ) ) )
    );
    }
    if ( is_tax( $tribe_ecp->get_event_taxonomy() ) && $depth ) {
    $cat = get_queried_object();
    $title = ‘‘ . $title . ‘‘;
    $title .= ‘ › ‘ . $cat->name;
    }
    return $title;
    }
    add_filter( ‘tribe_get_events_title’, ‘tribe_alter_event_archive_titles’, 11, 2 );

    /*
    * Remove hover events
    */
    function add_custom_script(){
    ?>

    jQuery(window).load(function(){
    jQuery(‘img’).removeAttr(‘title’);
    });

    single_event_meta, ‘link_venue’ ) );
    }
    add_action( ‘tribe_events_single_meta_before’, ‘tribe_remove_venue_link’, 100 );

    /$/
    add_filter( ‘tribe_reverse_currency_position’, function(){ return null; } );

    /*
    * Hides QR codes from the Email/Tickets sent to purchasers
    */
    function tribe_neuter_qr () {
    if ( class_exists( ‘Tribe__Tickets_Plus__Main’ ) ) {
    $qr_class = Tribe__Tickets_Plus__Main::instance()->qr();
    remove_action( ‘tribe_tickets_ticket_email_ticket_bottom’, array( $qr_class, ‘inject_qr’ ) );
    }
    }
    add_action( ‘init’, ‘tribe_neuter_qr’, 10 );

    /**
    * BCC site admin email on all Event Tickets’ RSVP ticket emails so they get a copy of it too
    *
    * From https://gist.github.com/cliffordp/4f06f95dbff364242cf54a3b5271b182
    *
    * Reference: https://developer.wordpress.org/reference/functions/wp_mail/#using-headers-to-set-from-cc-and-bcc-parameters
    *
    */
    function cliff_et_rsvp_bcc_admin_ticket() {
    // get site admin’s email
    $bcc = sanitize_email( get_option( ‘admin_email’ ) );

    // set Headers to Event Tickets' default
    $headers = array( 'Content-type: text/html' );
    
    // add BCC email if it's a valid email address
    if ( is_email( $bcc ) ) {
        $headers[] = sprintf( 'Bcc: %s', $bcc );
    }
    
    return $headers;
    

    }
    add_filter( ‘tribe_rsvp_email_headers’, ‘cliff_et_rsvp_bcc_admin_ticket’ );

    `

    #1416314
    Ryan
    Participant

    Hello,

    Unfortunately that code did not work either. Nothing is being sent. I have checked my spam folder.

    Thanks,
    Ryan

    #1421128
    Andras
    Keymaster

    Hi Ryan,

    Sorry to hear this still doesn’t work.

    Do you get other emails from the website? For example when you create a new user or when you change a password? If you also don’t receive those emails then that needs to be fixed first.

    Might be worth using an SMTP plugin for sending emails. These are usually much more reliable then the built-in function of WordPress.

    To eliminate the possibility of any conflicts with other plugins and customizations the best would be to deactivate all non-Modern Tribe plugins and to switch to a default theme like twentyseventeen and insert only the BCC email customization into the functions.php file of that theme.

    Could you give this a check?

    A.

    #1425763
    Ryan
    Participant

    Hi András,

    I appreciate your help. I’m sorry this isn’t resolved.

    I tried deactivating all plugins and using the 2017 default theme and unfortunately it still did not work. I am getting notification emails for orders and tickets without a problem, but am not getting the bcc from this php code.

    Thanks,
    Ryan

    #1426839
    Andras
    Keymaster

    Hi Ryan,

    I’m really sorry to hear that. Please give me some time so I can do some investigation. We’re currently experiencing a heavy load in the forums but I’ll try to get back to you in 2-3 days. Thanks for your patience.

    Cheers,
    Andras

    #1436250
    Andras
    Keymaster

    Hello Ryan,

    I’m sorry about the longer-than-expected waiting time. We got hit hard in the support forums and all 3 of our hands were full.

    Good news is I might have something that would do the trick for you.

    https://gist.github.com/niconerd/16770b84adb6156aaa77948bf208bacb

    As usual, put it in your functions.php. Once in place, the organizer of the event will receive an email.

    If you rather want a specific email address, then change line 12 like this:

    $to = '[email protected]';

    Also the content of this email is pretty limited, so you might need to adjust that, if you want more. It is in line 33 starting with ‘$content =’.

    And you can change the ‘$subject =’ as well. 🙂

    Hope this helps.

    Cheers,
    Andras

    #1450372
    Andras
    Keymaster

    Hi Ryan,

    Just wanted to get back in touch with you to see if the above helped you with your question.

    Let me know.

    Cheers,
    Andras

    #1461355
    Ryan
    Participant

    András,

    My name is David Lawson. I am a developer working with Ryan to correct the BCC issue. The tribe_rsvp_email_headers filter does not seem to be firing. The file where the filter is defined is definitely being reached, because a separate filter below it works find.

    I have verified that the site is able to send emails. I have verified that the rsvp email IS being sent. The BCC email is NOT sending.

    I have 2 questions:
    1. Are there certain conditions that need to be met before that filter will fire? If so, what are they?

    1. Do you have a recommended method for sending off a test email? I can not make a test purchase with my local machine, and this makes testing extremely difficult. If I can just circumvent the purchase and send the email directly, that will make this process go a whole lot faster.

    Thank you!
    David

    #1464254
    Andras
    Keymaster

    Hi Ryan, hi David,

    Thanks for reaching out again.

    The filter should be firing to the best of my knowledge. 2-3 people other than me have tested the snippets I sent you and it was working for all of us. So this is a curious case.

    I’m going to try to pull in an extra set of eyes to take a look at this.

    As for sending test emails, I have a test site set up under a subdomain and make test purchases there. Other than that I guess it depends on what you use on your local machine as a local server, and if that allows smtp / email sending.

    Andras

    #1469276
    Ryan
    Participant

    András,

    I dropped a variety of checkpoint logs into the function file, to let me know which blocks of code were definitely firing, and I have concluded with what I initially suspected: the RSVP filter is definitely NOT firing.

    As I stated before, other filters definitely ARE firing, so I feel like this problem is specific to The Events Calendar.

    Here is the snippet you provided as it exists in the functions.php file. Perhaps I am missing something?


    function cliff_et_rsvp_bcc_admin_ticket() {

    // get site admin's email
    $bcc = sanitize_email( get_option( 'admin_email' ) );
    
    // set Headers to Event Tickets' default
    $headers = array( 'Content-type: text/html' );
    
    // add BCC email if it's a valid email address
    if ( is_email( $bcc ) ) {
        $headers[] = sprintf( 'Bcc: %s', $bcc );
    }
    
    return $headers;
    

    }
    add_filter( ‘tribe_rsvp_email_headers’, ‘cliff_et_rsvp_bcc_admin_ticket’ );


    You said you were going to put some more eyes on this. What have you been able to discover?

    David

    #1469793
    Andras
    Keymaster

    Hi Ryan,

    I will still try to get someone to check this.

    I also looked through the code to check what is happening and why that might not fire.

    There are 2 checks before all the sending happens.

    1) The email will not be sent to those attendees/tickets which are marked as not attending

    and then

    2) Only add those attendees/tickets that haven’t already been sent

    This is done in:

    wp-content/plugins/event-tickets/src/Tribe/RSVP.php

    lines 677 to 689.

    We’ll get back to you with the second opinion.

    Cheers,
    Andras

    #1470764
    Andras
    Keymaster

    Hi folks,

    Thanks for your patience and I’m sorry about the slow progress on this.

    I would just like to note, that customizations like this are normally beyond the scope of our support. Nonetheless I’ll try to help you get this working for you but I cannot guarantee full success.

    The solutions I have provided before were tested and re-tested by us and they work on our test sites with the latest plugins. Thus we have no reason to believe the plugin is broken.

    During my internal discussion one question / detail came up, which we didn’t clarify before. Are trying to get bcc emails out for RSVPs or for Ticket purchases? The above snippets will work for RSVPs, but not for the tickets.

    If you want the bcc emails for Ticket / WooCommerce purchases, then likely you will need to hook into

    woocommerce_email_headers

    which is provided by WooCommerce and you can check how that works in their documentation.

    I also found this snippet on gist, which might give you a headstart on this:

    https://gist.github.com/jessepearson/fea13a281882b66d3a28d9b960312904

    I can try to give you some more pointers and guidance, but basically this is as much as I am able to help you with this.

    Hope this helps you move forward.

    Cheers,
    Andras

Viewing 15 posts - 1 through 15 (of 17 total)
  • The topic ‘Tickets email needs to send to customer and other email addresses.’ is closed to new replies.