mandatory picture upload snipped does not work since upload
-
Since update the following Code snipped leads to a bug when uploading picture in form:
add_filter( "adverts_form_load", "customize_adverts_add" ); function customize_adverts_add( $form ) { if( $form['name'] != "advert" ) { return $form; } adverts_form_add_validator("gallery_has_image_uploaded", array( "callback" => "gallery_has_image_uploaded", "label" => "", "params" => array(), "default_error" => "Please upload at least one picture", "validate_empty" => true )); foreach( $form["field"] as $key => $field ) { if( $field["name"] == "gallery" ) { $field["validator"] = array( array( "name" => "gallery_has_image_uploaded" ) ); } $form["field"][$key] = $field; } return $form; } function gallery_has_image_uploaded( $value ) { $post_id = adverts_request( "_post_id" ); $media = get_attached_media( 'image', $post_id ); if( count( $media ) > 0 ) { return true; } else { return false; } }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘mandatory picture upload snipped does not work since upload’ is closed to new replies.