/example.php Secret
Created
July 31, 2017 16:23
This is an example of how to add a Ninja forms form to an event that has any of the ticket types within it sold out.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php //Please do not include the opening PHP tag if you already have one | |
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file | |
// Display a contact form when the event is sold out | |
// to be used as a waiting list | |
function ee_espresso_any_sold_out_tickets( $event ) { | |
$tickets = $event instanceof EE_Event ? $event->tickets() : null; | |
if($tickets) { | |
foreach($tickets as $ticket) { | |
if($ticket->ticket_status() == EE_Ticket::sold_out){ | |
return true; | |
} | |
} | |
} | |
return false; | |
} | |
function ee_special_sold_out_message( $EVT_ID, $event ) { | |
//Set the ID of the Ninja Form you wish to call here. | |
$ninja_forms_id = 1; | |
//Check if the event is sold out. | |
if ( ee_espresso_any_sold_out_tickets( $event ) ) { | |
if( method_exists( 'Ninja_Forms', 'display') ) { | |
//Using Ninja Forms v3+ | |
Ninja_Forms()->display( $ninja_forms_id ); | |
} elseif( function_exists( 'ninja_forms_display_form' ) ) { | |
//Using a previous version of Ninja Forms | |
ninja_forms_display_form( $ninja_forms_id ); | |
} | |
} | |
} | |
add_action( 'AHEE__ticket_selector_chart__template__after_ticket_selector', 'ee_special_sold_out_message', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment