Theme Preprocess Conditional Field Display Looking for a way to preprocess two fields. I am trying to hide Field 1 from display if Field 2 has value.

If Field 1 has value and Field 2 has value display Field 2 only. 
If Field 1 has value and Field 2 has NO value display Field 1. 

This should only apply to content type USER POSTS. And I am using Display Suite to arrange the fields if that makes a difference. 

What would be the preprocess hook to place on mytheme.theme? 

Any help is greatly appreciated.
Can you hide it with CSS? In which case you could do something simple like:

&lt;?php

/**
 * Implements template_preprocess_hook().
 *
 * Adapt logic, field names etc to suit your needs.
 */
function MYTHEME_preprocess_page(&amp;$variables) {

  if (empty($variables['node']-&gt;get('my_field_2')-&gt;value)) {
    $variables['page_classes']['#plain_text'] .= ' field_two--display-none';
  } 

}

/* CSS */
.field_two--display-none { display: none; }


Not super elegant but would do the trick.

Your other option is to use the conditional fields module.