nf_get_object_children

Function that gets children objects by type and parent id.

Description

(array) nf_get_object_children( (string) $object_id, (string) $child_type = '', (constant) $full_data = true, (bool) $include_forms = true ); 

Returns (array)

$children

Parameters (4)

0. $object_id (string)
The object id.
1. $child_type — Optional. (string) => ''
The child type.
2. $full_data — Optional. (constant) => true
The full data.
3. $include_forms — Optional. (bool) => true
The include forms.

Usage

  1. if ( !function_exists( 'nf_get_object_children' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'ninja-forms/deprecated/includes/functions.php'; 
  3.  
  4. // The object id. 
  5. $object_id = ''; 
  6.  
  7. // The child type. 
  8. $child_type = ''; 
  9.  
  10. // The full data. 
  11. $full_data = true; 
  12.  
  13. // The include forms. 
  14. $include_forms = true; 
  15.  
  16. // NOTICE! Understand what this does before running. 
  17. $result = nf_get_object_children($object_id, $child_type, $full_data, $include_forms); 
  18.  

Defined (1)

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

/deprecated/includes/functions.php  
  1. function nf_get_object_children( $object_id, $child_type = '', $full_data = true, $include_forms = true ) { 
  2. global $wpdb; 
  3.  
  4.  
  5. if ( $include_forms ) { 
  6. if ( $child_type != '' ) { 
  7. $children = $wpdb->get_results( $wpdb->prepare( "SELECT child_id FROM " . NF_OBJECT_RELATIONSHIPS_TABLE_NAME . " WHERE child_type = %s AND parent_id = %d", $child_type, $object_id ), ARRAY_A); 
  8. } else { 
  9. $children = $wpdb->get_results( $wpdb->prepare( "SELECT child_id FROM " . NF_OBJECT_RELATIONSHIPS_TABLE_NAME . " WHERE parent_id = %d", $object_id ), ARRAY_A); 
  10. } else { 
  11. if ( $child_type != '' ) { 
  12. $children = $wpdb->get_results( $wpdb->prepare( "SELECT child_id FROM " . NF_OBJECT_RELATIONSHIPS_TABLE_NAME . " WHERE child_type = %s AND parent_id = %d AND parent_type <> 'form'", $child_type, $object_id ), ARRAY_A); 
  13. } else { 
  14. $children = $wpdb->get_results( $wpdb->prepare( "SELECT child_id FROM " . NF_OBJECT_RELATIONSHIPS_TABLE_NAME . " WHERE parent_id = %d AND parent_type <> 'form'", $object_id ), ARRAY_A); 
  15.  
  16. $tmp_array = array(); 
  17. if ( $full_data ) { 
  18. foreach( $children as $id ) { 
  19. $child_id = $id['child_id']; 
  20. $settings = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM " . NF_OBJECT_META_TABLE_NAME . " WHERE object_id = %d", $child_id ), ARRAY_A); 
  21. if ( ! empty( $settings ) ) { 
  22. foreach ( $settings as $s ) { 
  23. if ( is_array ( $s['meta_value'] ) ) { 
  24. $s['meta_value'] = unserialize( $s['meta_value'] ); 
  25. $tmp_array[ $child_id ][ $s['meta_key'] ] = $s['meta_value']; 
  26. } else { 
  27. $tmp_array[ $child_id ] = array(); 
  28.  
  29.  
  30. } else { 
  31. if ( is_array( $children ) ) { 
  32. foreach ( $children as $child ) { 
  33. $tmp_array[] = $child['child_id']; 
  34.  
  35. return $tmp_array;