Attendee List CSV and Email

Home Forums Ticket Products Event Tickets Plus Attendee List CSV and Email

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #956198
    Simon Groves
    Participant

    Good Morning,

    Having worked out how to add an additional column to the Attendee List page (https://theeventscalendar.com/support/forums/topic/attendee-list-add-guest-name-column/)

    Are you able to advise how I can add/include this information to the Email and Export data?

    Many thanks

    #956261
    George
    Participant

    Hey Simon,

    Unfortunately, like Gustavo mentioned in that original ticket you posted, we can’t provide much help for customizations…

    With that being said, though, the good news is that if your data is being stored properly, then yes, you should be able to access it from emails or exporting or anything else you need.

    For example, if the data is saved in a post_meta field for an event, then by default it should be automatically included in the the XML export data for an event if you export with the default WordPress exporter tool. If not, and you’d unfortunately have to write code that includes that data in the export process functions – you should look in the free wordpress.org/plugins repository for Export plugins, though. There might be ones that are easier to add custom data to than others, and it’s worth looking around for good ones.

    As for adding it to emails, if you mean adding it to the various emails sent out by The Events Calendar itself, then you can do this by customizing views in the plugin like /views/tickets/email.php, and just add code there that pulls in that custom data you’ve added. The exact methods would, again, depend on how you’ve added your added data and such, but for the gist of customizing plugin views like this, our official “Themer’s Guide” should give you a great understanding of how to customize plugin views from within your theme → https://theeventscalendar.com/knowledgebase/themers-guide/

    Sorry for the vague information here Simon, it’s hard to recommend a lot of specific code or anything because this is quite specific to your site and project’s needs. I hope the information here does help, and at least sparks some ideas or something.

    Cheers,
    George

    #956473
    Simon Groves
    Participant

    Thanks George,

    Surely if we use another plugin to export the information, even if it does included the new meta fields, it won’t be event specific like when you click the Attendee List export?

    If you could help with the code, I’d sure as heck appreciate it.

    I’ve got the code working for the new guest column which I posted here: https://theeventscalendar.com/support/forums/topic/attendee-list-add-guest-name-column/

    I just need to know how to include this in the email and CSV code. Is this something you can help with?

    Thanks

    #957221
    George
    Participant

    Hey Simon,

    We cannot write custom code, unless it’s a small tweak or something that extends a plugin filter we already have.

    My recommendation about another exporter plugin is just something that you may find helpful, if you find the default WordPress exporter insufficient. Despite that, the things I mentioned still hold true – meta data is included in XML files exported from WordPress via the default exporter, and if you want to include specific data in ticket emails, it shouldn’t be much more than a matter of programmatically calling functions like get_post_meta() to pull in the data you want in the main Tickets email template (/views/tickets/email.php).

    If I’m misunderstanding what you mean by “email”ing the data, and you do not mean including the data in the default tickets emails but rather mean mailing that information separately in another context, then sorry for the confusion – fortunately, it should still be somewhat straightforward to have that data emailed however you’d like, by assembling the data and mailing it with the wp_mail() function.

    I hope this information helps Simon – if custom code implementations are essential to your project here, we do have a list of freelancers that we often recommend to folks looking for advanced custom code support. If you’re interested in that list, shoot us an email at [email protected] about it and we can get it to you ASAP.

    — George

    #957284
    Simon Groves
    Participant

    Hi George,

    Thanks for the reply. Yes I think we’re talking at cross purposes!

    When you go to WP-Admin > Events > Event Attendee List

    You can Export the list of event attendees out as a CSV file.

    What I’d like to do, is simply include the Guest Names for the tickets. I’ve outlined how I did that here: https://theeventscalendar.com/support/forums/topic/attendee-list-add-guest-name-column/

    It “should” be simple but I can’t work out how to add the custom query into the existing code. Which from my understanding is lib/tickets/tribe-tickets-pro.php

    Hunting around, I can see so many people want this too, so not sure why it was never default functionality (but that’s another matter).

    So any help on this would be very much appreciated. I’ve even got the code to get the Guest Names, I just need to include the extra column into the existing Attendee List CSV file.

    I even tried altering
    $export_columns = array_diff_key( $columns, $hidden ); to $export_columns = array_diff_key( $columns, $hidden, $guests );

    Altering:

    
    $columns = $this->attendees_table->get_columns();
    $hidden  = get_hidden_columns( $this->attendees_page );
    

    To:

    
    $columns = $this->attendees_table->get_columns();
    $hidden  = get_hidden_columns( $this->attendees_page );
    $guests = 'Guest Names';
    

    But it’s then how to add the additional info

    Does that help/clarify what I’m trying to achieve?

    Thanks

    #957750
    George
    Participant

    Hey Simon,

    We cannot support customizations or custom code, especially one as complex as this.

    I feel like the code you’ve already written could cause serious problems on your site, and the code in that other ticket is not secure.

    So, even though this customization is a bit outside the scope of the support here, I will show you the general ideas of how to do this – you can take the reins from there and look up online anything you’re not very familiar with.

    So let’s break this down: in our example, I will be pulling in the user’s browser data since it is a Meta Value on the order – your custom “guest name” information seems to as well, so just adapt the get_post_meta() calls to your own needs.

    Part One: Registering the table column

    Plugin: The Events Calendar
    File: lib/tickets/tribe-tickets-attendees.php

    Look for the get_columns() method in this file’s main class. It should look something like this by default → https://cloudup.com/ccTBZ9polwG

    You can add a column header here following the pattern described in the comments above this function – for our demo here, we’ll use the very clever column handler example_testing and the header name Example. Adjust these values to your needs, but keep them consistent for your whole customization.

    Here’s how that get_columns() method looks after adding a new column header → https://cloudup.com/cxO4Sv5C_kO

    Part Two: Populating the new custom table column with data

    Plugin: None – Go to your active theme instead.
    File: Your theme’s functions.php file

    In your theme’s functions.php file, add a filter to The Events Calendar’s attendees table like so:

    
    if ( function_exists( 'tribe_is_event' ) {
    	/**
    	 * Populates a custom Attendees Table column with data.
    	 * @link http://m.tri.be/va
    	 */
    	function tribe_956198_example_column_testing( $value, $item, $column ) {
    
    		// Notice the 'example_testing' column handle here! Change to your needs.
    		if ( 'example_testing' !== $column || ! isset( $item['order_id'] ) || empty( $item['order_id'] ) ) {
    			return $value;
    		}
    	
    		return sanitize_text_field( get_post_meta( $item['order_id'], '_customer_user_agent', true ) );
    	}
    
    	add_filter( 'tribe_events_tickets_attendees_table_column', 'tribe_956198_example_column_testing', 20, 3 );
    }
    

    The use of ‘example_testing’ should instead the custom column handler you made for yourself – and the use of the ‘_customer_user_agent’ meta on the item’s order id should be changed to whatever meta value you need for the Guest Name.

    These two steps will add a column header and populate it with the necessary data. Here’s a screenshot of things now by using these two steps on my local test site → https://cloudup.com/cRuOKmr8enF

    Part Three: Adding the column and its data to the export file

    Plugin: the WooCommerce Tickets add-on
    File: /classes/class-wootickets.php

    The above two steps will not by themselves add the data to the CSV. So, to add this, head into the WooTickets add-on itself, and look for the main class-wootickets.php file.

    Once here, find the get_attendees() method, and look for the $attendees array here. It should look something like this → https://cloudup.com/cuwxMXSFSB0

    Now, remember in Step Two how we pulled the data for the column by using the get_post_meta() function? And how for my testing purposes, the meta key is ‘_customer_user_agent’? We accessed this data by using the following code:

    
    sanitize_text_field( get_post_meta( $item['order_id'], '_customer_user_agent', true ) );
    

    Here in Part Three in the class-wootickets.php file, we’ll use that same code again. Except instead of using $item[‘order_id’] to access the order ID, in the get_attendees() method we’re customizing we have access to just $order_id.

    So go back to that $attendees array screenshotted above, and add a key of the same column handler we started with all the way back in part one – ‘example_testing’, remember? – and the get_post_meta() call above.

    Here’s how this would look → https://cloudup.com/cAqUb7LFdPL

    Conclusion and Warnings

    After all this you should have a custom column, and when you “Export”, the column and data should be there. My screenshot cuts some of the data off, but here’s some proof – https://cloudup.com/cBbcNRFyZ5I

    There are a few very important things to note here:

    1. Auto-updating any of these plugins will over write these customizations and thus break things on your site. So before updating from now on, each time you will have to back up these customizations, update the plugins on your site, and then add the customizations back in manually.

    2. We cannot support customizations – if issues arise related to the custom code here, it’s unfortunately something outside the scope of the support forums and something you’d have to manage and wrestle with yourself.

    3. If you get this working with these methods, you should get rid of the original code you used and shared in your other forum post – the code that calls the Database directly. That is not safe code to have on your site.

    Go through all of this Simon, give it some time and look up anything you’re not familiar with. Let us know if it helps!

    — George

    #984076
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Attendee List CSV and Email’ is closed to new replies.