NinjaForm - 如何搜索&通过DateTime检索?

时间:2015-08-04 09:53:21

标签: wordpress wordpress-plugin

我在wordpress上使用NinjaForm插件。这里有如何搜索和检索数据:

<?php
$args = array(
  'form_id'   => $form_id,
  'user_id'   => $user_id,
  'fields'    => array(
    '34'      => 'checked',
    '54'      => 'Hello World',
  ),
);
// This will return an array of sub objects.
$subs = Ninja_Forms()->subs()->get( $args );
// This is a basic example of how to interact with the returned objects.
// See other documentation for all the methods and properties of the submission object.
foreach ( $subs as $sub ) {
  $form_id = $sub->form_id;
  $user_id = $sub->user_id;
  // Returns an array of [field_id] => [user_value] pairs
  $all_fields = $sub->get_all_fields();
  // Echoes out the submitted value for a field
  echo $sub->get_field( 34 );
}

我想要做的是按DateTime字段搜索。我怎么做? 我尝试过像这样的改变args但结果相同。

$args = array(
  'form_id'   => 5,
  'date_modified'=> '2015-07-25 3:19:09'
);

或者像这样

$args = array(
  'form_id'   => 5,
  'date_modified'=> '< 2015-07-25 3:19:09'
);

我做错了吗?

2 个答案:

答案 0 :(得分:0)

  1. 查找忍者数据库表:
  2. 使用phpmyadmin或其他东西进入你的数据库,找到Ninja Forms正在使用的表格。希望他们使用自己的桌子。如果没有,您可以在每个wp表中搜索一些您知道从Ninja_Forms()返回表单的arg数据。或者进入Ninja插件代码并尝试找到他们与db交互的位置,以找到他们写入的表。

    1. 编写自己的mysql搜索代码:
    2. 不使用Ninja的类进行搜索,而是使用wordpress内置的mysql搜索并抛出您在步骤1中找到的表。

      10, 8, 6, 4
      

      我没有测试过,但这将是我的行动方式。

答案 1 :(得分:0)

使用begin_date和end_data参数获取提交内容

key