I am trying to understand why a variable that contains an integer cannot but used to replace the integer in GFAPI::get_entries field_filters value. This works:
JavaScript
x
$search_criteria = array(
'status' => 'active',
'field_filters' => array(
'mode' => 'any',
array(
'key' => 'gpnf_entry_parent',
'value' => '72'
)
)
);
This does not work:
JavaScript
$child_entry_ID = "{entry_id}";
where $child_entry_ID is 72. Of course
JavaScript
echo $child_entry_ID . "<br />";
prints “72”
JavaScript
$search_criteria = array(
'status' => 'active',
'field_filters' => array(
'mode' => 'any',
array(
'key' => 'gpnf_entry_parent',
'value' => $child_entry_ID
)
)
);
I use it like this
JavaScript
$entry2 = GFAPI::get_entries(33, $search_criteria);
print_r($entry2);
In the case that works, my arrays print correctly, in the case that doesn’t work, I get “Array().
Advertisement
Answer
So it seems that when I put $child_entry_ID which is:
JavaScript
$child_entry_ID = "{entry_id}";
It echoes out to an integer (72 in this case) but is not interpreted as it’s result (72) but as a string ({entry_id}). I used the function rgar to change $child_entry_ID :
JavaScript
$child_entry_ID = rgar( $entry, 'id' );
And this works where the value is really interpreted as the result (72) and my search criteria interprets correctly.