How to validate review form?
-
I want to validate custom fields in standard comment form and in review form.
I try to use:function verification_test( $commentdata ) { // for test if ( is_product() ) { $test = "This is product page"; } else { $test = "This is NOT product page"; } if( is_product() ) { if( ! isset( $_POST['chb_review_test'] ) ) { wp_die( '<strong>ERROR: </strong>you must accept required fields.' . $test . '<p><a href="javascript:history.back()">' . __( '« Back' ) . '</a></p>'); } } else { if( ! isset( $_POST['chb_comment_test'] ) ) { wp_die( '<strong>ERROR: </strong>you must accept required fields.' . $test . '<p><a href="javascript:history.back()">' . __( '« Back' ) . '</a></p>'); } } return $commentdata; } add_filter( 'preprocess_comment', 'verification_test' );
Function is_product() not working – always returns “This is not product page”. And I can not validate my custom fields.
Is any filter like preprocess_comment dedicated for review form?The same problem is probably with:
add_action( 'comment_post', 'my_function' );
Any ideas?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘How to validate review form?’ is closed to new replies.