Accessing webform status via reference
You should avoid any complex PHP code in template files.  I recommend you use a THEME_preprocess_node_MY_CONTENT_TYPE(&amp;$vars) hook to perform your checks, then pass a variable to the template file for your basic validation.  In the preprocess function you pass the variable using $vars['my_custom_variable'] = XYZ and in the template you can call the variable with $my_custom_variable.

Make sure Drupal looks for content type node templates, or you can just use the default THEME_preprocess_node(&amp;$vars) and put a check for your content type in there to keep the full validation code from running.
https://www.drupal.org/node/337022

Stackoverflow discussion along similar lines
https://stackoverflow.com/questions/40645297/pass-variable-to-preprocess-node-function-for-use-in-node-template