• Hi everybody,

    I was facing the common “Required Radio Validation” problem too.
    The solution from andrew[at]message2medium.com didn’t worked for me at first try for some reason.

    Maybe because I’m using the multi-step extension…
    I didn’t had time to investigate further and found another solution here, thanx to ‘Google Translate’ ??

    Add this to your (child) theme’s functions.php :

    add_filter( 'wpcf7_validate_radio', 'my_validate_radio', 10, 2 );
    function my_validate_radio( $result, $tag ) {
    	$type = $tag['type'];
    	$name = $tag['name'];
    
    	if ( 'radio' == $type ) {
    		if ( !isset( $_POST[$name] ) || '' == $_POST[$name] ) {
    			$result['valid'] = false;
    			$result['reason'] = array( $name => wpcf7_get_message( 'invalid_required' ) );
    		}
    	}
    	return $result;
    }

    And you’ll not be able to submit your form with unpopulated radio buttons!!

    Hope this help…

    https://www.ads-software.com/plugins/contact-form-7/

  • The topic ‘Required Radio Button Validation Solution 2’ is closed to new replies.