Block user upon one webform submission I'm using Drupal 8, and I'm trying to block a user after submitting a certain webform. I have the below scenario:


Only authenticated user can submit and use the webform
Webform submission is limited to once per user
Users can save drafts of the webform and continue filling it later on
Rules action or otherwise should take place when the user has logged in


I tried to use Rules with rules_webform module but to no avail. The actions in rules are all there, but I need a condition to detect if the user has submitted the webform completely, not saved it as a draft only.

Appreciate any help given

Thanks
The best way to do this is to write your own webform handler and attach it to the webform's postSave() method. You can also experiment and try another method if needed from WebformHandlerBase.

Webform handlers are not documented well, but they should be because they are quite useful.

modules/custom/mymodule/src/Plugin/WebformHandler/MyModuleWebformHandler.php

&lt;?php

namespace Drupal\mymodule\Plugin\WebformHandler;

use Drupal\webform\Plugin\WebformHandlerBase;
use Drupal\webform\WebformSubmissionInterface;

/**
 * Webform example handler.
 *
 * @WebformHandler(
 *   id = "mymodule_webform_handler",
 *   label = @Translation("My Module Webform Handler"),
 *   category = @Translation("My Module"),
 *   description = @Translation("Block users after submission"),
 *   cardinality = \Drupal\webform\Plugin\WebformHandlerInterface::CARDINALITY_UNLIMITED,
 *   results = \Drupal\webform\Plugin\WebformHandlerInterface::RESULTS_PROCESSED,
 *   submission = \Drupal\webform\Plugin\WebformHandlerInterface::SUBMISSION_OPTIONAL,
 * )
 */

class MyModuleWebformHandler extends WebformHandlerBase
{

  /**
   * {@inheritdoc}
   */
  public function postSave(WebformSubmissionInterface $webformSubmission, $update = TRUE)
  {
    if (!$webformSubmission-&gt;isDraft()) {
      $webformSubmission-&gt;getOwner()-&gt;block();
    }
  }

}


After getting that setup, enable your new module (don't forget an info.yml file) and then edit your webform settings > handlers to add this to that particular form.