• I have a form with a text field and i need to check if it exists any entry with the same value before sending the e-mail.

    I try this:

    add_action( ‘wpcf7_before_send_mail’, ‘check_rg’ );

    function check_rg( $cf7 ){
    	$args = array(  'post_type'  => 'inscricao','meta_query'  => array(array('value' => $cf7->posted_data["rg"])));
    	$my_query = new WP_Query( $args );
    	if( $my_query->have_posts() ) {
      		$cf7->skip_mail = true;
    		echo "<script type='text/javascript'>alert('Duplicate Entry');</script>";
    	}
    	wp_reset_postdata();
    }

    It works, but after the alert, the data fields turn empty and the success message appears bellow.

    Any idea to do it better way?

    https://wordpress.org/plugins/contact-form-7/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Check duplicate entry’ is closed to new replies.