webform_get_submissions() in Drupal 7 return all the Webform submissions, the problem is that I want to return the submission that falls between 2 date
ex: get webform submissions that have been submitted between 16 April 2018 and 28 April 2018.
Let me share a workaround that I came up with, maybe it will help you to find a full-size solution.
You actually can use a filter in the function webform_get_submissions
not only by nid
or sid
but apparently by any other field. In this case, there is possible to use a filter by a field named submitted
:
$submissions = webform_get_submissions(array('nid' => $node->nid, "submitted" => "1503753434"));
It will result in recieiving a submission which field submitted
is exactly equal to 1503753434
. To get all submissions which are, for example, newer than 1503753434
one way is inside a file includes/webform.submissions.inc
for the function webform_get_submissions_query
change this part:
foreach ($filters as $column => $value) {
$pager_query->condition($column, $value);
}
to this part:
foreach ($filters as $column => $value) {
if ($column == "submitted") {
$pager_query->condition($column, $value, ">");
} else {
$pager_query->condition($column, $value);
}
}
This would result in getting submissions which are newer than 1503753434
. By analogy we can add <
filter or any other filters.
The problem with this workaround is that it requires to change a source file of Drupal and also it requires implementing a simple parsing by hand in case we want to have several conditions for one field name.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.