nf_create_form_listen

Listen for a new form action and create one if necessary.

Description

nf_create_form_listen(); 

Usage

  1. if ( !function_exists( 'nf_create_form_listen' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'ninja-forms/deprecated/includes/admin/pages/ninja-forms/tabs/field-settings/field-settings.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = nf_create_form_listen(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/deprecated/includes/admin/pages/ninja-forms/tabs/field-settings/field-settings.php  
  1. function nf_create_form_listen() { 
  2. $page = isset ( $_REQUEST['page'] ) ? $_REQUEST['page'] : ''; 
  3. $tab = isset ( $_REQUEST['tab'] ) ? $_REQUEST['tab'] : ''; 
  4. $form_id = isset ( $_REQUEST['form_id'] ) ? $_REQUEST['form_id'] : ''; 
  5.  
  6. if ( 'ninja-forms' == $page && 'builder' == $tab && 'new' == $form_id ) { 
  7. $defaults = apply_filters( 'nf_new_form_defaults', array( 
  8. 'clear_complete' => 1,  
  9. 'hide_complete' => 1,  
  10. 'show_title' => 0,  
  11. 'status' => 'new',  
  12. ) ); 
  13. $form_id = Ninja_Forms()->form()->create( $defaults ); 
  14. $redirect = esc_url_raw( add_query_arg( array( 'form_id' => $form_id ) ) ); 
  15. wp_redirect( $redirect ); 
  16. die();