【问题标题】:Variable not working when an integer works fine in Gravity Forms GFAPI::get_entries filter当整数在重力形式 GFAPI::get_entries 过滤器中正常工作时变量不起作用
【发布时间】:2019-07-28 07:59:25
【问题描述】:

我试图理解为什么一个包含整数的变量只能用来替换 GFAPI::get_entries field_filters 值中的整数。 这有效:

$search_criteria = array(
'status'        => 'active',
'field_filters' => array(
'mode' => 'any',
    array(
        'key'   => 'gpnf_entry_parent',
        'value' => '72'
    )
)
);

这不起作用:

$child_entry_ID = "{entry_id}";

$child_entry_ID 是 72。当然

echo $child_entry_ID . "<br />";

打印“72”

$search_criteria = array(
'status'        => 'active',
'field_filters' => array(
    'mode' => 'any',
    array(
        'key'   => 'gpnf_entry_parent',
        'value' => $child_entry_ID
    )
)
);

我是这样用的

$entry2 = GFAPI::get_entries(33, $search_criteria); 
print_r($entry2);

在有效的情况下,我的数组打印正确,在无效的情况下,我得到“Array()。

【问题讨论】:

    标签: php forms variables filter gravity


    【解决方案1】:

    所以当我输入 $child_entry_ID 时,它似乎是:

    $child_entry_ID = "{entry_id}";
    

    它回显为一个整数(在本例中为 72),但不会被解释为它的结果 (72),而是一个字符串 ({entry_id})。 我使用函数 rgar 来更改 $child_entry_ID :

    $child_entry_ID = rgar( $entry, 'id' );
    

    这适用于将值真正解释为结果 (72) 并且我的搜索条件解释正确的情况。

    【讨论】:

      【解决方案2】:

      我知道这是旧的,但不应该

      $child_entry_ID = "{entry_id}";
      

      其实是:

      $child_entry_ID = "{$entry_id}";
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-06-14
        • 1970-01-01
        • 2013-05-28
        • 1970-01-01
        • 2015-05-26
        • 2013-09-22
        • 2017-12-27
        • 2019-11-12
        相关资源
        最近更新 更多