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:
$search_criteria = array(
'status' => 'active',
'field_filters' => array(
'mode' => 'any',
array(
'key' => 'gpnf_entry_parent',
'value' => '72'
)
)
);
This does not work:
$child_entry_ID = "{entry_id}";
where $child_entry_ID is 72. Of course
echo $child_entry_ID . "<br />";
prints "72"
$search_criteria = array(
'status' => 'active',
'field_filters' => array(
'mode' => 'any',
array(
'key' => 'gpnf_entry_parent',
'value' => $child_entry_ID
)
)
);
I use it like this
$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().
So it seems that when I put $child_entry_ID which is:
$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 :
$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.
I know this is old, but shouldn't
$child_entry_ID = "{entry_id}";
Actually be:
$child_entry_ID = "{$entry_id}";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.