# pdf-for-wpforms/trunk/preview.php

PDF for WPForms + Drag and Drop Template Builder, version trunk. 40 lines.

- Page: https://pluginprobe.com/plugins/pdf-for-wpforms/trunk/code/preview.php
- Raw: https://pluginprobe.com/plugins/pdf-for-wpforms/trunk/raw/preview.php
- Modified: 2025-06-20T14:14:44+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/pdf-for-wpforms/trunk/code/preview.php#L10-L20`.

```php
<?php 
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if( isset($_GET['id'])) {
    $id_template = sanitize_text_field( $_GET['id'] );
    $type = "preview";
    if( isset($_GET["download"]) ){
        $type = "download";
    }
    if( isset($_GET["html"]) ){
        $type = "html";
    }
    $name ="pdf_name";
    if( isset($_GET["pdf_name"]) ){
        $name = sanitize_text_field($_GET["pdf_name"]);
        $name = urldecode($name);
        $name = sanitize_file_name($name);
    }
    $user = wp_get_current_user();
    $allowed_roles = array('editor', 'administrator', 'author',"shop_manager");
    $check = false;
    if ( isset( $_REQUEST['_wpnonce']) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'yeepdf' ) ) {
        $check = true;
    }
    if( array_intersect($allowed_roles, $user->roles ) ) {
        $check = true;  
    }
    if( $check ){
        $order_id = "";
        if( isset($_GET["woo_order"]) ) {
            $order_id = sanitize_text_field( $_GET['woo_order'] );
        }
        $data_send_settings = array(
            "id_template"=> $id_template,
            "type"=> $type,
            "woo_order_id" =>$order_id,
            "name" => $name
        );
        Yeepdf_Create_PDF::pdf_creator_preview($data_send_settings);
    }
}
```
