【问题标题】:Count Entries by field in Gravity Forms在重力形式中按字段计数条目
【发布时间】:2015-10-25 09:48:41
【问题描述】:

我需要使用后端的 Gravity Forms 条目部分输出条目计数。 具体来说,我需要通过过滤器下拉列表中出现的“参展商名称”来计算有多少条目。

我有这个 sn-p 输出所有条目的总数。任何有关如何修改它的帮助将不胜感激。

$form_id = 1;

$search_criteria['field_filters'][] = array( 'key' => 'exhibitor_name' );

$sorting = array();
$total_count = 0;
$result = GFAPI::count_entries( $form_id, $search_criteria, $sorting, $total_count );
echo $result;

【问题讨论】:

    标签: php wordpress gravity-forms-plugin


    【解决方案1】:

    看这段代码sn-p

    $startdate = 2015-12-30; //(Y-m-d format) optional
    $enddate = 2015-12-31; //(Y-m-d format) optional
    $search_criteria = array(
    'status'     => 'active', //optional
    'start_date' => $startdate, //optional
    'end_date'   => $enddate, //optional
    'field_filters' => array(
        array(
            'key'   => '3', //this is the field id of your drop-down
            'value' => 'exhibitor_name'
        )
      )
    );
    
    $entry_count = GFAPI::count_entries(1, $search_criteria); // 1 is your form id
    echo $entry_count;
    

    【讨论】:

      猜你喜欢
      • 2017-12-16
      • 2018-07-23
      • 1970-01-01
      • 2017-06-04
      • 2017-06-10
      • 1970-01-01
      • 1970-01-01
      • 2021-12-13
      相关资源
      最近更新 更多