Custom CSS

My Tickets provides relatively sparse default styles. These styles are intended to do the minimum necessary to make My Tickets usable, and reasonably attractive as long as the theme doesn’t impose too many changes.

My Tickets is intended to be customized. You can add your own styles through your theme, but it’s also very easy to override all of My Tickets default CSS. If you add a stylesheet called ‘mt-cart.css’ into a directory in your theme called ‘css’, that stylesheet will be used in place of the default My Tickets stylesheet.

Because the CSS used by My Tickets is designed to be overridden, there’s a very good chance that much of the styles will be overridden by various characteristics of your theme. This is intentional, to keep My Tickets light-weight and easy to modify, but does have consequences if you don’t have the knowledge or experience to customize stylesheets.

Customizing CSS is outside what is provided as support for My Tickets, but if you need assistance, you can submit a support request to hire Joe Dolson Accessible Web Design for customization tasks or to point you towards a developer who can help you.

Custom Field API

If you’re selling tickets, it’s not uncommon that you’ll need to gather some form of custom information. Do you need your customers to check a box verifying that they’re over 18? Do you need to get a phone number for each event? Find out which meal a customer would prefer for lunch?

My Tickets supports a custom field API that can add a custom field into the “Add to Cart” form. What it does is largely up to you; but it’s very easy to write a basic extension to collect custom data for an event.

Custom fields are added using the filter ‘mt_custom_fields‘.

In the filter, all you need to do is add an array of data to the custom fields array that passes the label for your custom field, a sanitization callback function, a display callback function, an input type, a set of values to choose from, and a context.

Any of these values can be omitted except for the label.

If you only provide a label, you will create a text input field with no default value. It’ll be sanitized using esc_sql and strip_tags. The display callback will call esc_attr and stripslashes on the value for display. When you create a callback, your callback gets two arguments: the data value itself, and the context it’s shown in. That will either by ‘cart’, for the shopping cart or add to cart context, or ‘payment’, if it’s being shown in the admin.

Supported input types include all the basic inputs, but do not currently include an upload field or other media selection method.

The context for the field defaults to ‘global’, but you can also pass a specific event ID or an array of event IDs. This rule defines where the custom field will show up – with ‘global’, it’ll show up on all add to cart forms. To create custom rules for displaying custom fields, use the ‘mt_apply_custom_field_rules‘ filter.

Example Implementation

add_filter( 'mt_custom_fields', 'create_custom_fields', 10, 1 );
function create_custom_fields( $array ) {
	// Other fields: sanitize callback; input type; input values; display_callback
	$array['test_event_data'] = array( 
		'title'=>"Meal preference", 
		'input_values'=>array( 'Chicken', 'Salad', 'Doughnut' ),
		'context'=> 'global'
	return $array;

/* Display callback formats the saved data. $context is 'payment' or 'cart', depending on whether it appears in an admin payment or the user's shopping cart. */
function display_callback( $data, $context='payment' ) {
	return urldecode( $data );

/* Sanitize callback cleans the data before saving to the DB */
function sanitize_callback( $data ) {
	return esc_sql( $data );

Adding a custom field will also automatically add this data into the Payments reports and will create a template tag so you can use the custom field in your automatic response emails.

Script Resources

My Tickets enqueues a small number of useful scripts you can take advantage of in your theme or custom extension to My Tickets. One that’s particular useful if you’re writing a custom payment gateway is jQuery Payments, the jQuery plug-in by Stripe for validating and handling credit card payment information.

Additionally, the AJAX actions used by My Tickets to add, remove, and update the shopping cart have hooks usable to handle custom actions during shopping cart updates. See the filters and actions reference for more assistance with My Tickets’ filters and actions.


There are two key shortcodes available for My Tickets. There’s a basic shortcode to display the ‘Add to Cart’ form for a single event:

[ticket event='{ID}']

This shortcode is displayed in the settings when you create a ticketed event, and you can paste it anywhere to render an add to cart form for that event. You don’t need to use it on the event page itself, although you certainly can.

The second shortcode is for displaying a collection of tickets:

[tickets events='14,29,38' template='<h3>{post_title}: {event_begin format="l, F d"}</h3><p>{post_excerpt}</p>']

This shortcode will render the add to cart forms for the IDs provided, using the template provided. The example above is the default, and is what you’ll see if you don’t use the template attribute. The registration form itself will appear after the templated data. The entire output will be wrapped in a div element with the class mt-event-item.


There are four areas of My Tickets that are templatable:

  • receipts,
  • tickets,
  • the opt-out form for email notifications,
  • and the ticket verification screen used by ticket-takers.

Templates can be customized in the standard WordPress way: take a copy of the file from wp-content/plugins/my-tickets/templates/, place it at the root of your theme directory, and edit it until it does what you want.

By default, the templates load their CSS within the template, and you can modify CSS directly within your template or load external styles.

All My Tickets specific templating functions are in the file my-tickets/mt-templating.php. All functions prefixed with `mt_get_` will `return` the data for manipulation in PHP; all functions without `get_` will `echo` the result.