ninja_forms_get_form_ids_by_post_id

The Ninja Forms ninja forms get form ids by post id function.

Description

ninja_forms_get_form_ids_by_post_id( $post_id ); 

Parameters (1)

0. $post_id
The post id.

Usage

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

Defined (1)

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

/deprecated/includes/database.php  
  1. function ninja_forms_get_form_ids_by_post_id( $post_id ) { 
  2. global $wpdb; 
  3. $form_ids = array(); 
  4. if( is_page( $post_id ) ) { 
  5. $form_results = ninja_forms_get_all_forms(); 
  6. if(is_array($form_results) AND !empty($form_results)) { 
  7. foreach($form_results as $form) { 
  8. $form_data = $form['data']; 
  9. if(isset($form_data['append_page']) AND !empty($form_data['append_page'])) { 
  10. if($form_data['append_page'] == $post_id) { 
  11. $form_ids[] = $form['id']; 
  12. $form_id = get_post_meta( $post_id, 'ninja_forms_form', true ); 
  13. if( !empty( $form_id ) ) { 
  14. $form_ids[] = $form_id; 
  15. }else if( is_single( $post_id ) ) { 
  16. $form_id = get_post_meta( $post_id, 'ninja_forms_form', true ); 
  17. if( !empty( $form_id ) ) { 
  18. $form_ids[] = $form_id; 
  19.  
  20. return $form_ids;