我在Drupal中构建了多个webforms。我想要用户
我该怎么做?
答案 0 :(得分:0)
unique
并查看User email as default
,如果您的网络表单中有一个。由于您可能不希望为您的webforms(或者不是所有这些)添加其他webform组件,因此您始终可以创建一个模块,包含webform功能并在hook_form_alter()
的webform实例上检索提交的数据。 :
/**
* Implements hook_form_alter().
*/
function YOUR_MODULE_form_alter(&$form, &$form_state, $form_id) {
// get current user
global $user;
// include webform functionality
module_load_include('inc','webform','includes/webform.submissions');
// make sure to only alter webform forms
if (strpos($form_id, 'webform_client_form_') !== FALSE) {
// check if the user is a an authenticated user
if (in_array('authenticated user', $user->roles)) {
// build $filters array for submission retrieval
$filters = array(
'nid' => $form['#node']->webform['nid'],
'uid' => $user->uid,
);
/**
* When not using a unique webform component for 1 submission
* you can use a submission of the user on a webform instance
* to prevent another submission.
*/
// get submissions of the user by webform nid
if ($submissions = webform_get_submissions($filters)) {
// disable the form to limit multiple submissions per instance
$form['#disabled'] = TRUE;
/**
* Webform instance submission data of the current user
* can be found in $submissions[1]->data array
*/
# render your submission with Form api
}
}
}
}
希望这有帮助。
答案 1 :(得分:0)
每个网络表单只能提交1次提交,可以通过网络表单完成 - >表单设置 - >提交的总提交限制和每用户提交限制,如此屏幕截图所示
要自动加载用户提交,因为上面不允许您通过使用他们已经提交的网络表单的提交ID来显示网络表单。基于此code
module_load_include('inc','webform','includes/webform.submissions');
$sid = 10;
$submission = webform_get_submissions(array('sid' => $sid));
$nid = $submission[$sid]->nid;
$web_submission = webform_get_submission($nid, $sid);
$node = node_load($nid);
$output = webform_submission_render($node, $web_submission, NULL, 'html');
print $output;