2015-08-03 98 views
0

我需要輸出具有後端Gravity Forms條目部分的條目數。 具體而言,我需要根據過濾器下拉列表中顯示的「參展商名稱」來計算多少條目。在重力形式中按字段計數條目

我有這個片段輸出所有條目的總數。任何幫助如何修改這將是最讚賞。

$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; 

回答

1

看這段代碼

$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;