Disable (Close) webform form dynamically
Webforms are config entities and you can use hook_webform_load() to close the webform before it is rendered and then altered. Instead of closing and resaving the webform, you can call $webform-&gt;setPropertyOverride('status', FALSE); which will safely close the webform and prevent it from being permanently closed.