Skip to content

Instantly share code, notes, and snippets.

@skyshab
Created March 29, 2021 13:38
Show Gist options
  • Select an option

  • Save skyshab/bc1eec781c003aa275ca0264967a074e to your computer and use it in GitHub Desktop.

Select an option

Save skyshab/bc1eec781c003aa275ca0264967a074e to your computer and use it in GitHub Desktop.
Prepend event name to ticket on creation
<?php
add_action( 'tribe_tickets_ticket_add', function( $post_id, $ticket ){
$post_title = get_the_title( $post_id );
if( strpos( $ticket->name, $post_title ) === 0 ) return;
$new_name = $post_title . ' - ' . $ticket->name;
$args = [
'ID' => $ticket->ID,
'post_title' => $new_name
];
wp_update_post( $args );
}, 100, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment