• Resolved pgk37

    (@pgk37)


    Hi

    I use your plugin (great) to secure a client site.
    On this site I use the WordPress PDF Templates plugin (with the DomPDF library)
    When I want to access the PDF, even identified, they are not generated.

    Could you tell me if there is anything in particular to do?

    best regards
    Bertrand

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Kevin Vess

    (@kevinvess)

    Hi– thanks for using Force Login!

    I’m not familiar with that plugin, so I can’t say exactly why it doesn’t work with Force Login.

    However, I suspect the service that is generating the PDF is not recognized as a logged in user when it tries to access the site and generate the PDF. Force Login blocks public access to all pages of the site, including when other third-party services try to access the site.

    You might need to use the v_forcelogin_bypass filter to add an exception in Force Login to allow this plugin and its PDF generating service to access the site without logging in. Check out the FAQ for examples on how to use that filter.

    You’ll need to dig into the other plugin code to figure out what your conditional (if) statement should be to determine when the site is being visited by that plugin/PDF service and allow it access.

    If you find a solution for this, please share it here in case some one else runs into this same issue.

    Good luck!

    Thread Starter pgk37

    (@pgk37)

    Hello Kevin

    Thank you for your response and your help.

    Effectively I actually tested the bypass filter but without success ??
    It was my first idea when i read your documentation.

    Here is the function I used. I think my condition on the URL is not taken by the plugin.

    function my_forcelogin_bypass( $bypass ) {
        // Get visited URL without query string
        $url_path = preg_replace('/\?.*/', '', $_SERVER['REQUEST_URI']);
    
        // Autorisation pour les fiches produits
        if ( '/single-fiches-produits.php' === $url_path  || '/single-fiches-produits-pdf.php' === $url_path) {
            $bypass = true;
        }
        return $bypass;
    }
    add_filter( 'v_forcelogin_bypass', 'my_forcelogin_bypass' );

    I use a template who’s name is “single-fiches-produits.php” for website (works great) and DompPDF for PDF works with “name-template-pdf.php”
    but when i try to generate my PDF the PDF display the login Page of WordPress…

    DomPDF used this url format : http(s)://my_web_site_url)/pdf
    In PHP done this : <?php the_permalink(); ?>pdf

    I think it’s due to URL path but I can’t solve this problem;
    I’m using the WordPress rewrited url (pretty url).

    If I find the solution of course I will share the solution ??
    Bertrand

    Plugin Author Kevin Vess

    (@kevinvess)

    Unless you want to list specific page URLs to allow public access, it sounds like you’re trying to allow access based on the theme’s page template being used?

    The page URL path is not always going to be the same as the page template filename. I recommend you use the is_page_template() function in your conditional statement if you’re trying to allow access based on the page template being used.

    Keep in mind, allowing access to a page based on its URL path or page template will allow any visitor to those pages access to it.

    If you only want to allow the logged-in user access to these pages, you will need to dig into the other plugin code (or ask their support) to find a way to identify if the PDF generator is accessing the page and not just any visitor.

    Good luck!

    Thread Starter pgk37

    (@pgk37)

    Thank you for your reply. Indeed I want to hide the whole site from unidentified users.

    So I set up the condition on the template pages concerned.

    For unidentified users the redirection is done well.

    For identified users, the PDF no longer displays the WordPress login screen but a blank page.
    The filter therefore seems to be partly working…

    There is progress.

    I’ll see if I can contact the developer of “WordPress PDF Templates” (which uses the DomPDF library).

    Thank you again for your help

    Plugin Author Kevin Vess

    (@kevinvess)

    If the screen is blank, try enabling WP_DEBUG to see if any errors are being thrown.

    If you’re using the WordPress PDF Templates plugin, that plugin was last updated 5 years ago and hasn’t been tested with the latest 3 major releases of WordPress. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.

    Good luck!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Impossible to generate PDF Files (DomPDF )’ is closed to new replies.