Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Forked from Pebblo/functions.php
Last active October 16, 2017 03:29
Show Gist options
  • Save joshfeck/01e26f06c58ddf711e0c3bb45ac56de4 to your computer and use it in GitHub Desktop.
Save joshfeck/01e26f06c58ddf711e0c3bb45ac56de4 to your computer and use it in GitHub Desktop.
Add a ninja form to a Sold out Event Espresso 4 event. This is useful if you want to capture names and contact info from people that want to be signed up for a waiting list.
<?php
//* 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_clean_event_status( $event ) {
$status = $event instanceof EE_Event ? $event->get_active_status() : 'inactive';
return $status;
}
function ee_special_sold_out_message( $EVT_ID, $event ) {
//Set the ID of the Ninja Form you wish to call here.
$ninja_forms_id = 6;
//Check if the event is sold out.
if ( ee_espresso_clean_event_status( $event ) == 'DTS' ) {
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