How to hide a webform field from a node display when the per-user submission limit has been reached I have a Webform field on my node, which links to an application form. The form is set to allow one submission per user (per node). I want the link to disappear after the user has submitted the form. 

Any good ways to do this?
This works (below, added to MY_THEME.theme), but I haven't stress-tested it:

function TEMPLATE_preprocess_node(&amp;$variables) {
  // Hide field_registration_form if already submitted to it.
  if($variables['node']-&gt;bundle() == 'CONTENT_TYPE') {
    $current_user = \Drupal::currentUser();
    $uid = $current_user-&gt;id();
    $webform = Webform::load('WEBFORM_ID');
    if ($webform-&gt;hasSubmissions()) {
      $query = \Drupal::entityQuery('webform_submission')
        -&gt;condition('webform_id', 'WEBFORM_ID');
      $result = $query-&gt;execute();
      $submission_data = [];
      foreach ($result as $item) {
        $submission = \Drupal\webform\Entity\WebformSubmission::load($item);
        $submission_data[] = $submission-&gt;getData()['user'];
      }
      if (in_array($uid, $submission_data)) {
        unset($variables['content']['field_registration_form']);
      }
    }
  }
}