wordpressmicrosoft-edgelearndash

Learndash Plugin - Corrupted pdf certificate (edge)


I am using the latest version (4.12.1) of Learndash plugin and WordPress version 6.5.2.

The issue I am facing is when (a number of users) try to print/export their certificate in Microsoft Edge they get an error message "We can't open this file something went wrong". I tested it all firefox, brave and google chrome and it works fine for every single one of those in different machines too. But, in "machines" the Edge returns this problem.

Some details, Only Learndash runs as a plugin.

My work around idea was to tweak the code and make the file to auto-download instead of opening in a new tab, but the result was a corrupted file that wont open anywhere.

The big question is: Is this a bug with Learndash ? If yes is there any tweaks to fix it for now ? or is this a problem with Microsoft Edge ?


Solution

  • The "problem" eventually was: - opening/downloading the pdf file under a language endpoint of a plugin that was installed in WordPress.

    I added a script plugin to fix the problem:

    document.addEventListener("DOMContentLoaded", function () {
        var certificateLinky = document.querySelectorAll(".ld-certificate-link");
    
        certificateLinky.forEach(element => {
            if (element.href.includes('el'))
            {
                console.log(element.href, 'contains el');
    
                element.href = element.href.replace('el/', '');
                console.log('new link', element.href);
            }
            if (element.href.includes('fr'))
            {
                console.log(element.href, 'contains fr');
    
                element.href = element.href.replace('fr/', '');
                console.log('new link', element.href);
            }
        });
    
        // console.log(certificateLinky);
    });