-
-
Save LeoLopesWeb/412495259a37a495f4a4a5889142f63f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // testa se o campo CPF (Contact form 7) já existe no banco de dados na tabela 'wp_cf7_vdata_entry' (plugin: Advanced Contact form 7 DB) | |
| add_filter( 'wpcf7_validate_text', 'alphanumeric_validation_filter', 20, 2 ); | |
| add_filter( 'wpcf7_validate_text*', 'alphanumeric_validation_filter', 20, 2 ); | |
| function alphanumeric_validation_filter( $result, $tag ) { | |
| $tag = new WPCF7_Shortcode( $tag ); | |
| if ( 'your-cpf' == $tag->name ) { | |
| $cpf = $_POST['your-cpf']; | |
| global $wpdb; | |
| $count = $wpdb->get_var("SELECT COUNT(*) FROM wp_cf7_vdata_entry WHERE value = '$cpf'"); | |
| if ( $count ) { | |
| $result->invalidate( $tag, "Esse CPF não pode ser cadastrado novamente" ); | |
| } | |
| } | |
| return $result; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment