Support » Plugin: WPAdverts - Classifieds Plugin » allow customers to upload a PDF?

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

    (@gwin)

    Hi,
    if you have access to the Custom Fields extension then you can add a new file upload field to the [adverts_add] form that will accept PDF files or allow uploading the PDF files to the Gallery.

    If you do not have the CF extension the easiest solution would be to allow uploading the PDF to the gallery (as the code snippet for that is rather simple).

    You can do it 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 $key => $field ) {
            if( $field["name"] != "gallery" ) {
                continue;
            }
            $form["field"][$key]["validator"] = array();
            $form["field"][$key]["validator"][] = array(
                "name" => "upload_type",
                "params" => array( 
                    "allowed" => array( "image", "video" ), 
                    "extensions" => array( "pdf" )    
                )
            );
        }
        return $form;
    } );
    
Viewing 1 replies (of 1 total)
  • The topic ‘allow customers to upload a PDF?’ is closed to new replies.