title: wordpress how I can compare custom field entry with values in a database table?
body: <p>I have this piece of code that give me the possibility to add and validate a custom field during registration process.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>//1. Add a new form element...
  add_action( 'register_form', 'myplugin_register_form' );
  function myplugin_register_form() {
  
      $esp_n_1 = ( ! empty( $_POST['esp_n_1'] ) ) ? trim( $_POST['esp_n_1'] ) : '';
          
          ?&gt;
          &lt;p&gt;
              &lt;label for="esp_n_1"&gt;&lt;?php _e( 'Termostato n. 1', 'mydomain' ) ?&gt;&lt;br /&gt;
                  &lt;input type="text" name="esp_n_1" id="esp_n_1" class="input" value="&lt;?php echo esc_attr( wp_unslash( $esp_n_1 ) ); ?&gt;" size="25" /&gt;&lt;/label&gt;
          &lt;/p&gt;
          &lt;?php
      }
  
      //2. Add validation. In this case, we make sure first_name is required.
      add_filter( 'registration_errors', 'myplugin_registration_errors', 10, 3 );
      function myplugin_registration_errors( $errors, $sanitized_user_login, $user_email ) {
          
          if ( empty( $_POST['esp_n_1'] ) || ! empty( $_POST['esp_n_1'] ) &amp;&amp; trim( $_POST['esp_n_1'] ) == '' ) {
              $errors-&gt;add( 'esp_n_1_error', __( '&lt;strong&gt;ERROR&lt;/strong&gt;: You must include a Serial number.', 'mydomain' ) );
          }
          
          return $errors;
      }
  
      //3. Finally, save our extra registration user meta.
      add_action( 'user_register', 'myplugin_user_register' );
      
      function myplugin_user_register( $user_id ) {    
          if ( ! empty( $_POST['esp_n_1'] ) ) {
              update_user_meta( $user_id, 'esp_n_1', trim( $_POST['esp_n_1'] ) );
          }
      }</code></pre>
  </div>
  </div>
  </p>
  
  <p>But I need one more mandatory validation:
  When the user submit the form I ned wordpress to check if the custom field data is already present in a column of a table ( I think iterating trough it ), If found the registration process go ahead, if not it raise error message.</p>
  
  <p>I hope someone can help this question.</p>
  
  <p>Best regards</p>