ninja_forms_display_form

Main function used to display a Ninja Form.

Description

ninja_forms_display_form( (string) $form_id = '' ); 

ninja_forms_display_form" title="ninja_forms_display_form" class="code function">ninja_forms_display_form() can be called anywhere on in a WordPress template. By default it's called by the ninja_forms_append_to_page" title="ninja_forms_append_to_page" class="code function">ninja_forms_append_to_page() function in the main ninja_forms.php file.

Parameters (1)

0. $form_id — Optional. (string) => ''
The form id.

Usage

  1. if ( !function_exists( 'ninja_forms_display_form' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'ninja-forms/deprecated/includes/display/form/display-form.php'; 
  3.  
  4. // The form id. 
  5. $form_id = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = ninja_forms_display_form($form_id); 
  9.  

Defined (2)

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

/deprecated/includes/display/form/display-form.php  
  1. function ninja_forms_display_form( $form_id = '' ) { 
  2. //Define our global variables 
  3. global $post, $wpdb, $ninja_forms_fields, $ninja_forms_loading, $ninja_forms_processing; 
  4.  
  5. //Get the settings telling us whether or not we should clear/hide the completed form. 
  6. //Check to see if the form_id has been sent. 
  7. if($form_id == '') { 
  8. $function = false; 
  9. if(isset($_REQUEST['form_id'])) { //If it hasn't, set it to our requested form_id. Sometimes this function can be called without an expressly passed form_id. 
  10. $form_id = absint( $_REQUEST['form_id'] ); 
  11. }else{ 
  12. $function = true; 
  13. if($form_id != '') { //Make sure that we have an active form_id. 
  14. do_action( 'nf_before_display_loading', $form_id ); 
  15.  
  16. // Instantiate our loading global singleton. 
  17. if ( !isset ( $ninja_forms_processing ) or ( isset ( $ninja_forms_processing ) and $ninja_forms_processing->get_form_ID() != $form_id ) ) { 
  18. $ninja_forms_loading = new Ninja_Forms_Loading( $form_id ); 
  19.  
  20. // Run our two loading action hooks. 
  21. do_action( 'ninja_forms_display_pre_init', $form_id ); 
  22. do_action( 'ninja_forms_display_init', $form_id ); 
  23.  
  24. if ( isset ( $ninja_forms_loading ) ) { 
  25. $ajax = $ninja_forms_loading->get_form_setting( 'ajax' ); 
  26. } else { 
  27. $ajax = $ninja_forms_processing->get_form_setting( 'ajax' ); 
  28.  
  29. if ( !$ajax ) { 
  30. $ajax = 0; 
  31.  
  32. if ( isset ( $ninja_forms_loading ) ) { 
  33. $logged_in = $ninja_forms_loading->get_form_setting( 'logged_in' ); 
  34. } else { 
  35. $logged_in = $ninja_forms_processing->get_form_setting( 'logged_in' ); 
  36.  
  37. if ( !$logged_in ) { 
  38. $logged_in = 0; 
  39.  
  40. $display = true; 
  41.  
  42. if( $logged_in == 1 ) { 
  43. if( !is_user_logged_in() ) { 
  44. $display = false; 
  45.  
  46. $display = apply_filters( 'ninja_forms_display_show_form', $display, $form_id ); 
  47.  
  48. if($ajax == 1) { 
  49. $url = admin_url( 'admin-ajax.php' ); 
  50. $url = esc_url_raw( add_query_arg('action', 'ninja_forms_ajax_submit', $url ) ); 
  51. }else{ 
  52. $url = ''; 
  53.  
  54. if( $display ) { 
  55. do_action( 'ninja_forms_before_form_display', $form_id ); 
  56.  
  57. do_action('ninja_forms_display_open_form_wrap', $form_id); 
  58.  
  59. do_action('ninja_forms_display_form_title', $form_id); 
  60.  
  61. do_action('ninja_forms_display_before_form', $form_id); 
  62. do_action('ninja_forms_display_open_form_tag', $form_id); 
  63.  
  64. do_action('ninja_forms_display_before_fields', $form_id); 
  65. do_action('ninja_forms_display_fields', $form_id); 
  66. do_action('ninja_forms_display_after_fields', $form_id); 
  67.  
  68. do_action('ninja_forms_display_close_form_tag', $form_id); 
  69. do_action('ninja_forms_display_after_form', $form_id); 
  70.  
  71. do_action('ninja_forms_display_close_form_wrap', $form_id); 
  72. do_action('ninja_forms_display_after_form_wrap', $form_id); 
  73.  
  74. do_action( 'ninja_forms_after_form_display', $form_id ); 
  75.  
  76. do_action( 'ninja_forms_display_js', $form_id ); 
  77. do_action( 'ninja_forms_display_css', $form_id ); 
  78. }else{ 
  79. do_action( 'ninja_forms_display_user_not_logged_in', $form_id ); 
/includes/deprecated.php  
  1. function ninja_forms_display_form( $form_id = '' ) { 
  2. Ninja_Forms::deprecated_notice( 'ninja_forms_display_form', '3.0', 'Ninja_Forms()->display( $form_id, $is_preview )', debug_backtrace() ); 
  3. Ninja_Forms()->display( $form_id );