简体   繁体   English

按字段值过滤重力表单条目

[英]Filter Gravity Forms Entries by field value

I am trying to echo out a list of Gravity Forms Entries, but only want to echo out the entries that have a certain value, within a certain field. 我试图回显重力形式条目的列表,但只想回显某个字段中具有特定值的条目。

So for example, $entry['53'] is a field within the form that allows the user to select from a dropdown. 因此,例如,$ entry ['53']是表单中的一个字段,允许用户从下拉列表中进行选择。 There are only two options. 只有两个选择。 Let's say A and B. How would I go about altering my code below to only show entries that have a value of B ? 假设A和B。如何更改下面的代码以仅显示值为B的条目?

The code I have at the moment is: 我目前的代码是:

<?php
      //Get the Form ID to get the entries from and store it within a varibale

      $search_criteria = null;
        $sorting = null;
        $paging = null;

        $entries = GFAPI::get_entries( $form_id, $search_criteria, $sorting, $paging );

        echo '<ul>';
            foreach($entries as $entry) :
                echo '<li>Title: ' . $entry['2'] . '</li>';
            endforeach;
        echo '</ul>';
  ?>

Many Thanks 非常感谢

Try this: 尝试这个:

$search_criteria = array(
        'status'        => 'active',
        'field_filters' => array(
            array(
                'key'   => '53',
                'value' => 'B',
            ),
        )
    );

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

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