简体   繁体   English

当 integer 在 Gravity Forms GFAPI::get_entries 过滤器中正常工作时,变量不起作用

[英]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.我试图理解为什么包含 integer 的变量不能用于替换 GFAPI::get_entries field_filters 值中的 integer。 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其中 $child_entry_ID 是 72。当然

echo $child_entry_ID . "<br />";

prints "72"打印“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().在有效的情况下,我的 arrays 打印正确,在无效的情况下,我得到“Array().

So it seems that when I put $child_entry_ID which is: 因此,当我放入$ child_entry_ID时,它似乎是:

$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}). 它回显为整数(在这种情况下为72),但不会解释为结果(72),而是字符串({entry_id})。 I used the function rgar to change $child_entry_ID : 我使用函数rgar更改$ 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. 这适用于将值真正解释为结果(72)并且我的搜索条件正确解释的情况。

I know this is old, but shouldn't我知道这很旧,但不应该

$child_entry_ID = "{entry_id}";

Actually be:实际上是:

$child_entry_ID = "{$entry_id}";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM