I have a webform on my site with the settings of "Per user submission limit" to "Limit each user to 1 submission(s) ever " so I tested this out and after I submit the form I do get the message "You have already submitted this form." but the form is gone and all you see is that message and the title of the form. I'd like to have a block show up where the form should be or if there's a way to display the form without the submit button that would be an option as well. Any help would be greatly appreciated. Thanks in advance.

Comments

fineartist99 created an issue. See original summary.

dev18.addweb’s picture

To place the block when user form submission limit has reached, please add the following code in your custom module:

..
..
function posting_preprocess_page(&$variables) {
  global $user;
  $count = 1;
  $user_limit = 1; //place your user limit here
  $result = webform_get_submissions('webform_node_id');
  foreach($result as $key => $value) {
    if($user->uid == $value->uid) {
      $count++;
    }
  }
  if($count > $user_limit) {
    $block = module_invoke('views', 'block_view', 'your_block_id'); //place 
    print render($block['content']);
  }
}
..
..

Thanks

fineartist99’s picture

In my custom module, I don't have any custom modules nor do I know how to develop one. I appreciate the reply but I don't know what to do with it. Maybe I'll try placing that within the actual form itself via php code and see what happens. I'll let you know.

Subhransu.addweb’s picture

Hi fineartist99,

Steps for creating custom module.

1) Go to modules directory and create folder call custom(i.e. sites/all/modules/custom).

2) In custom folder create one .info file like custom.info, and write below code

name = custom
description = first custom module
package = custom
core = 7.x

3) Create another file called custom.module in custom directory. Inside the custom.module write the below code

<?php
/**
 * @file
 * Custom functions for this site.
 */

4) check your project module page (i.e. /admin/modules) and your module is available.

>> put above code with some modification

function custom_preprocess_page(&$variables) {// write module name at starting of your hook like custom
  global $user;
  $count = 1;
  $user_limit = 1; //place your user limit here
  $result = webform_get_submissions('webform_node_id');// write your webform id like '9'
  foreach($result as $key => $value) {
    if($user->uid == $value->uid) {
      $count++;
    }
  }
  if($count > $user_limit) {
    $block = module_invoke('views', 'block_view', 'your_block_id'); //put your custom block
    print render($block['content']);
  }
}

If you have further query please feel free to ask me.

Thanks!

Liam Morland’s picture

Status: Active » Fixed

If you need more help, please re-open.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.