title: Trying to check a user entered value against one stored in database; always returns error?
body: <p>I'm working on a sort-of registration system for a Wordpress site. The bulk of the work is done with the "Formidable Forms Pro" WP plugin. </p>
  
  <p>In the system a code is generated for each player that has been 'accepted'. The player is then sent an email with the code and is expected to enter it in a field on another form.</p>
  
  <p>I would post this question on the Formidable support form but... they don't help with custom code.</p>
  
  <p>Basically, the issue is that no matter what code is entered in the field the error message is ALWAYS returned, even if the code is in fact in the database. I'm not sure what I've done wrong - and am unsure of how I can debug this in Wordpress. I have checked that my field values (stored as globals for the time being) are correct and they are.</p>
  
  <p>Anyways, here's the php function in question:</p>
  
  <pre><code>add_filter('frm_validate_field_entry', 'validatePlayerPassCode', 10, 3);
  function validatePlayerPassCode($errors, $posted_field, $posted_value)
  {
      global $wpdb;
      global $code_entry_field;
      global $code_field;
  
      if ($posted_field-&gt;id == $code_entry_field) {
          $prefix = $wpdb-&gt;prefix;
  
          $actual_codes = $wpdb-&gt;get_results(
              $wpdb-&gt;prepare(
                  "SELECT meta_value FROM %s WHERE field_id = %d",
                  $prefix . "frm_item_metas",
                  $code_field
              ));
  
          if (in_array($posted_value, $actual_codes)) {
              return;
          }
  
          $errors['field'. $posted_field-&gt;id] = '&lt;p&gt;Failed to register player, player passcode incorrect.&lt;/p&gt;';
      }
  
      return $errors;
  }
  </code></pre>
  
  <p>To sum up, what is wrong in this code of mine that causes <strong>correct</strong> codes to still be read as wrong?</p>
  
  <p>Thanks!</p>