Skip to content
Advertisement

Variable not working when an integer works fine in Gravity Forms GFAPI::get_entries filter

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().

Advertisement

Answer

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.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement