title: How to check if a custom field has specific value
body: <p>I'm trying to create a new post (type event) every time one of my posts is updated and custom_field has the value 'ja'.
  I don't understand why the if query  if($customfield == 'ja'){}
  doesn't work.</p>
  
  <pre><code>function create_event($post_id, $post, $post_before){
  if (get_post_type($post) == 'product') {
      $customfield=get_post_meta($post_id, 'custom_field');
      if ($customfield == 'ja') { //this if query doesn't work
          $author = $post-&gt;post_author;
          $event = array(
              'post_type' =&gt; 'tribe_events',
              'post_title' =&gt; get_the_author_meta('firmenname', $author),
              'meta_input' =&gt; array('post_id' =&gt; $post_id, '_EventStartDate' =&gt; '2019-06-04 00:00', '_EventEndDate' =&gt; '2019-06-04 23:59',
                  'test'=&gt;$customfield)
          );
          wp_insert_post($event);
      }
  }
  add action('post_updated', 'create_event', 10, 3);
  </code></pre>