Get All Attendee's Email Address

Home Forums Ticket Products Event Tickets Plus Get All Attendee's Email Address

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #1181964
    slny311
    Participant

    Currently I have A mutli-Ticket event where each Ticket Obtains the Ticket holder’s Info such as Name and Email, I pre-populate The Ticket info for Member Only Tickets, and Guest tickets just fills out the info themselves.

    I attached a filter to the CSV Export function tribe_events_tickets_attendees_csv_items

    with a New array that looks like this
    $newarray = array( array(‘Ticket #’, ‘Ticket’,’First Name’, ‘Last Name’, ‘Email Address’, ‘Organization Name’, ‘Order ID’, ‘Order Status’, ‘Customer Name’, ‘Customer Email Address’) );

    I now Need to read this output on the fronted’s search member as you type function to filter out the members who have already brought a ticket.

    which contains a User search query with the current Event_ID passed to the function.

    with a loop output function :
    echo $user->first_name . ‘ ‘ . $user->last_name . $user_org . “<span style=’display:none;’> | “. $user->user_email.”</span>\n”;

    I searched for the core function and found the following
    Tribe__Tickets__Tickets_Handler.php -> generate_filtered_attendees_list( $eventid );

    which calls the filter at the very end and applies it, but I cannot use this since it is a private function.
    How can I get the current Attendee’s Email Address?

    Below is my user output function.

    function se_lookup() {
        global $wpdb;
    
        $search = sanitize_text_field($_REQUEST['q']);
        $eventid = sanitize_text_field($_REQUEST['id']);
    	//$method = new ReflectionMethod( 'Tribe__Tickets__Tickets_Handler', 'generate_filtered_attendees_list');
    	//$method->setAccessible(true);
    	//echo $method->invoke( new Tribe__Tickets__Tickets_Handler(), $eventid);
    	
    	
        $args = array(
    		'search' => '*'. $search .'*'
    	);
    	$wp_user_query  = new WP_User_Query( $args );
    	$users = $wp_user_query->get_results();
    		foreach ($users as $user) {
    			if (wc_memberships_is_user_active_member($user->ID, 'member')){
    				if (get_user_meta($user->ID, 'directory_company_name', true)){
    					$user_org = ' | ' . get_user_meta($user->ID, 'directory_company_name', true);
    				} else { $user_org = " | N/A"; }
    				echo $user->first_name . ' ' . $user->last_name  . $user_org . "<span style='display:none;'> | ". $user->user_email."</span>\n";
    			}
    		}
        die();
    }
    #1182083
    slny311
    Participant

    edit

    • This reply was modified 7 years, 6 months ago by slny311.
    #1182645
    Brook
    Participant

    Howdy slny311,

    That is an awesome interface you’re building.

    Just to make sure I’m on the same page, let me recap. Your goal here is to access the output of Tribe__Tickets__Tickets_Handler::generate_filtered_attendees_list() but you can’t because it’s private. If you can access that, then you can finish building your customization, correct?

    I do not have a chance to test your code right now, I am headed to a meeting. But, if you get back to me before the meeting is over, could you clarify why the ReflectionMethod is commented it out? Did it not work, or did you just not like using that because it’s “bad form”?

    Cheers!

    – Brook

    #1182726
    slny311
    Participant

    The reflection method caused Errors when I tried to run it.

    Since I hooked into the CSV output array filter to Format the different forms into the same output columns, I really want to be able to access the CSV output before it gets put into a file stream, so I can just read that array and do a match and remove for all email that are already in the system.

    bottom line is I need some way to return me an array of existing attendee email so I can filter output of search as you type function to exclude those who have already brought their tickets from buying another.

    – on a sidenote
    When adding the tickets in and -> Add to Cart. if a user press the back button or refresh, both keeps some type of post data and messes up the event page or the cart pages.

    – back button -> shows tickets forms again but all empty
    – refresh button -> form post resubmits to cart

    Thank you for all the help!
    ( if you want I can reply with all the required parts to reproduce the basic example of mine setup )

    • This reply was modified 7 years, 6 months ago by slny311.
    #1185713
    slny311
    Participant

    Any status update on this?

    #1186456
    Brook
    Participant

    I am very sorry slny, this topic had a mismarked status indicating it had already received a response. My mistake!

    Since I hooked into the CSV output array filter to Format the different forms into the same output columns, I really want to be able to access the CSV output before it gets put into a file stream, so I can just read that array and do a match and remove for all email that are already in the system.

    Hooking into the filter ‘tribe_events_tickets_attendees_csv_export_columns’ is a great way to accomplish this. It sounds like that’s what you’ve already done, so you should be good on this front. The only thing remaining is to get you the attendee list elsewhere.

    bottom line is I need some way to return me an array of existing attendee email so I can filter output of search as you type function to exclude those who have already brought their tickets from buying another.

    It sounds to me like all you need is the public static function:

    Tribe__Tickets__Tickets::get_event_attendees()

    This will generate a list of attendees, and from there you would have the data you need to filter with. Does that look right to you?

    – back button -> shows tickets forms again but all empty

    This behavior often varies from browser to browser. Personally I have never seen an HTML spec indicating what DOM state the browser should be in when the back button is pressed. Which would be a good reason for the behavior to vary.

    – refresh button -> form post resubmits to cart

    That sounds like a bug. I see that it’s been logged a few days back, so it’s one we plan to address. To be up front I would not be surprised if it takes a while to fix that though. Users to rarely press the refresh button, it is unlikely to impact the extreme majority of sites. Plus a lot of browsers warn you when resbumitting data like that, indicating that unexpected behavior might happen. Thus this would naturally be a lower priority bug then one that impacts more users.

    Please let me know if you have any more questions. Cheers!

    – Brook

     

    #1186509
    slny311
    Participant

    This will generate a list of attendees, and from there you would have the data you need to filter with. Does that look right to you?

    Yes I need to be able to access that function which returns an array for excel output.
    I can just filter the list with that listing.

    That sounds like a bug. I see that it’s been logged a few days back, so it’s one we plan to address. To be up front I would not be surprised if it takes a while to fix that though. Users to rarely press the refresh button, it is unlikely to impact the extreme majority of sites. Plus a lot of browsers warn you when resbumitting data like that, indicating that unexpected behavior might happen. Thus this would naturally be a lower priority bug then one that impacts more users.

    Please let me know if you have any more questions. Cheers!

    I will be looking into ajaxing the add to cart part of the plugin.

    #1186531
    Brook
    Participant

    Yes I need to be able to access that function which returns an array for excel output.
    I can just filter the list with that listing

    In that case you could copy/paste the logic in Tribe__Tickets__Tickets_Handler.php->generate_filtered_attendees_list() into a new function. It references a few $this variables, but you could copy the contents of those to inside the new function and reference them instead. Then you could output it in the excel format if that is your preference.

    This might not be necessary though if all you care about is the attendee data. Tribe__Tickets__Tickets::get_event_attendees() outputs the same data, it’s just not formatted for Excel/CSV. Rather it’s formatted for use within PHP scripts. From what I am gathering from your first post you are not trying to output this for Excel, rather you are just using this to power your Add Member bar. In which case I would just use from Tribe__Tickets__Tickets::get_event_attendees() and not worry about making a public version of the other function.

    Totally up to your preference, you’re familiar with your goals better than I am.

    I will be looking into ajaxing the add to cart part of the plugin.

    That’s a cool idea. It would certainly work around the refresh bug.

    Cheers!

    – Brook

    #1186558
    slny311
    Participant

    This reply is private.

    • This reply was modified 7 years, 6 months ago by slny311.
    • This reply was modified 7 years, 6 months ago by Brook.
    #1186585
    Brook
    Participant

    That makes sense now. When I saw that was outputting a purchaser email I was thinking that’s what you were after, but on second thought obviously you want the attendee email. In that case making a public version of the other function would be the easiest route.

    – Brook

     

    #1186988
    slny311
    Participant

    Finished this part of coding project after reading through how your private function gets the csv exports.

    function se_lookup() {
        global $wpdb;
    
        $search = sanitize_text_field($_REQUEST['q']);
        $event_id = sanitize_text_field($_REQUEST['id']);
    	do_action( 'tribe_events_tickets_generate_filtered_attendees_list', $event_id ); 
    	$items = Tribe__Tickets__Tickets::get_event_attendees( $event_id );
    	$emailstring = '';
    	foreach( $items as $item ){
    		$ticket_meta  = get_post_meta( $item['attendee_id'],'_tribe_tickets_meta', true );
    		foreach ($ticket_meta as $key=>$single_meta){
    			if(($key=='email-address')||($key=='member-email')){
    				$emailstring .= $single_meta . ', ';
    			}
    		}
    	}
        $args = array(
    		'search' => '*'. $search .'*'
    	);
    	$wp_user_query  = new WP_User_Query( $args );
    	$users = $wp_user_query->get_results();
    		foreach ($users as $user) {
    			if ((wc_memberships_is_user_active_member($user->ID, 'member')) && (strcmp($user->user_email, $emailstring)>0) ){
    				if (get_user_meta($user->ID, 'directory_company_name', true)){
    					$user_org = ' | ' . get_user_meta($user->ID, 'directory_company_name', true);
    				} else { $user_org = " | N/A"; }
    				echo $user->first_name . ' ' . $user->last_name  . $user_org . "<span style='display:none;'> | ". $user->user_email."</span>\n";
    			}
    		}
        die();
    }
    #1187024
    Brook
    Participant

    That’s good to hear. Thanks for sharing the result!

    – Brook

    #1197399
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

Viewing 13 posts - 1 through 13 (of 13 total)
  • The topic ‘Get All Attendee's Email Address’ is closed to new replies.