wpcf7_acceptance_filter

The Contact Form 7 wpcf7 acceptance filter function.

Description

wpcf7_acceptance_filter( $accepted ); 

Parameters (1)

0. $accepted
The accepted.

Usage

  1. if ( !function_exists( 'wpcf7_acceptance_filter' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'contact-form-7/modules/acceptance.php'; 
  3.  
  4. // The accepted. 
  5. $accepted = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wpcf7_acceptance_filter($accepted); 
  9.  

Defined (1)

The function is defined in the following location(s).

/modules/acceptance.php  
  1. function wpcf7_acceptance_filter( $accepted ) { 
  2. if ( ! $accepted ) 
  3. return $accepted; 
  4.  
  5. $fes = wpcf7_scan_form_tags( array( 'type' => 'acceptance' ) ); 
  6.  
  7. foreach ( $fes as $fe ) { 
  8. $name = $fe['name']; 
  9. $options = (array) $fe['options']; 
  10.  
  11. if ( empty( $name ) ) 
  12. continue; 
  13.  
  14. $value = ( ! empty( $_POST[$name] ) ? 1 : 0 ); 
  15.  
  16. $invert = (bool) preg_grep( '%^invert$%', $options ); 
  17.  
  18. if ( $invert && $value || ! $invert && ! $value ) 
  19. $accepted = false; 
  20.  
  21. return $accepted;