• Resolved maaper

    (@maaper)


    Dear all, is there any way to mark upload file as a mandatory field?
    I think that there is a missed check even on the custom fields add-on.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    using the Custom Fields extension you can require users to upload at least one image to the gallery when posting an Ad.

    If you do not have access to CF, you can do the same by adding the code below in your theme functions.php file

    
    add_filter( "adverts_form_load", function( $form ) {
        if( $form["name"] != "advert" ) {
            return $form;
        } 
        foreach( $form["field"] as $k => $field ) {
            if( $field["name"] == "gallery" ) {
                $form["field"][$k]["validator"][] = array(
                    "name" => "upload_limit",
                    "params" => array( "min" => 1, "max" => 10 )
                ); 
            }
        }
        return $form;
    } );
    

    (this will force users to upload at least one file but no more than 10)

    Thread Starter maaper

    (@maaper)

    Thanks!!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Upload mandatory’ is closed to new replies.