I'd like to limit the ability of a form submission based on whether a user has submitted the form already.

So basically if a user has submitted a form, they can not submit again. I've already created the form using webforms, I just need to figure out how to limit the submissions now.

1 Answer 1


Webform has already this option, that you can find in the Submission settings. Otherwise, if you need to check something more you still can use some Webform hooks.

But if you need more complex submission checking, the best way from my point of view is to add a validate callback with the help of hook_form_alter().


Here is an example how to use the hook_form_alter(); For it, you must install the module Devel before.

// First you have to create your module
// you will find more information about it
// here http://drupal.org/node/231276
function mymodule_form_alter(&$form, &$form_state, $form_id) {
  // To add your validate callback to any form, you must find
  // the right form_id before
  // the form_id is an id that identify the form
  // from all that drupal can generate.
  // My solution to find it quickly its to show
  // all form_id with the help of Devel
  dsm($form, $form_id);
  // This will show you a drupal_set_message with something like that
  // form_id_form => Array()…
  // When you found the form that you want add the validate callback you
  // change it like that
  if($form_id == 'the_form_id') {
    $form['#validate'][] = 'mymodule_myvalidate';

function mymodule_myvalidate(&$form, &$form_state) {
  // Here you can see want you receive
  // by checking the content of $form_state
  // still with Devel, like that

  // You should see the values in $form_state['values']
  // After you can make your additional checks and retur errors like that
  if($error) {
    form_set_error('field_error', t("You can balbla"));
  • I'm sorry, but my understanding of hooks is still a little shakey. Do I just create a random module and use the hook within a new module?
    – kylex
    Commented Sep 21, 2011 at 21:03
  • Before to think about hooks, is it enough the built-in feature that allow user submit only one time your formulae or you need more checks ?
    – yvan
    Commented Sep 21, 2011 at 21:08
  • I need more checks as well. I need to check it against another table to see if the user is involved in certain projects.
    – kylex
    Commented Sep 21, 2011 at 21:12
  • I edited my answer, hope its can help you.
    – yvan
    Commented Sep 21, 2011 at 21:32
  • I think that's gonna help me get going on this issue. Thank you so much!
    – kylex
    Commented Sep 21, 2011 at 21:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.