How to make a custom comment file upload field required?
I have so far build and integrated the file upload in comment field via filter now I WANT TO make it a required field I tried the class="required" not working then i tried the other hook method as defined but so far its not a field of text its not working either
function custom_validate_comment() {
//validate for brief and rating
if( empty( $_POST['image']) )
wp_die( __('Error: you must upload an image') );
//make comment not required
add_action('pre_comment_on_post', 'custom_validate_comment');
I have so far build and integrated the file upload in comment field via filter now I WANT TO make it a required field I tried the class="required" not working then i tried the other hook method as defined but so far its not a field of text its not working either
function custom_validate_comment() {
//validate for brief and rating
if( empty( $_POST['image']) )
wp_die( __('Error: you must upload an image') );
//make comment not required
add_action('pre_comment_on_post', 'custom_validate_comment');
No comments:
Post a Comment