2015-06-04 107 views

回答

0
  • 您可以使用電子郵件的網頁表單組件,將其設置爲unique並檢查User email as default,如果你有一個在你的網絡表單。
  • 自動加載webform提交可能是可能的,通過創建一個具有上下文過濾器的視圖塊給用戶提供了與webform的關係的uid提供&。

正如你可能不希望爲您的WebForms額外的網頁表單組件(或者不是全部),你總是可以創建一個模塊,包括網絡表單功能並與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 
      } 

     } 

    } 

} 

希望這會有所幫助。

0

限制到每網絡表單只有1提交可以通過網絡表單來完成 - >表格設置 - >總提交極限與如本截圖

enter image description here 自動裝載用戶的提交,每用戶提交限制以來以上不會允許您通過使用他們已經提交的網絡表單的提交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;