nf_get_object_parent

Get an object's parent.

Description

(int) nf_get_object_parent( (int) $child_id ); 

Returns (int)

$parent_id

Parameters (1)

0. $child_id (int)
The child id.

Usage

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

Defined (1)

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

/deprecated/includes/functions.php  
  1. function nf_get_object_parent( $child_id ) { 
  2. global $wpdb; 
  3. // Check our relationship table for where this ID appears as a child. 
  4. $parent = $wpdb->get_row( $wpdb->prepare( 'SELECT parent_id FROM ' . NF_OBJECT_RELATIONSHIPS_TABLE_NAME . ' WHERE child_id = %d', $child_id ), ARRAY_A ); 
  5. return $parent['parent_id'];