• Hi, thanks for this great plugin.
    I am testing the plugin on a new website with Divi using the shortcodes: [sdm_download id=”246″ fancy=”0″] and [sdm_download_counter id=”246″] in a text module.
    When i enter the correct password, the protected download works great but when i enter a wrong password, i am redirected to an error page and from a link on the error page i am redirected to a new page where i can correct the password.
    Is it possible to configure the Simple Download Monitor in a way that when a wrong password is entered, i stay on the original page and a message like wrong password is showing in stead of the redirection.

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor mbrsolution

    (@mbrsolution)

    Thank you for reaching out to us. Please let me know if you are talking about the following feature?

    https://simple-download-monitor.com/how-to-password-protect-your-wordpress-downloads/

    Kind regards.

    Thread Starter benny54

    (@benny54)

    That’s correct. Meanwhile i found a workaround by creating an own shortcode that runs a php file with a password field and embeds the SDM shortcode without the SDM passsword protection. This works for me.

    Plugin Contributor mbrsolution

    (@mbrsolution)

    That is good news ?? Perhaps if you don’t mind, you might like to share your solution for others that might run into the same issue as yourself.

    Kind regards.

    Thread Starter benny54

    (@benny54)

    My workaroud to place a password protected download on my website is the following.
    I placed the below code in my child themes functions.php.
    In this code you first have to edit your desired password and the sdm_download id for your desired download.
    Now when you place the shortcode [password_protected_download] in a text module (in my case in Divi) you will see an input field for the password and only when the password is correct the sdm download button is showing.

    function password_protected_download_shortcode($atts) {
    // Define the fixed password (change this to your desired password)
    $fixed_password = 'ThisIsMyPassword'; // Change this to your desired password

    // Variable to track if the password is correct
    $is_password_correct = false;

    // Check if the form has been submitted and if the password is correct
    if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['password'])) {
    $submitted_password = sanitize_text_field($_POST['password']);
    if ($submitted_password === $fixed_password) {
    $is_password_correct = true;
    }
    }

    // HTML content for the form or the result
    ob_start();

    if (!$is_password_correct) {
    // Password is incorrect or hasn't been submitted yet
    ?>
    <form method="POST" action="">
    <label for="password">Wachtwoord: </label>
    <input id="password" name="password" required>
    <input type="submit" value="Verzend">
    </form>
    <?php
    } else {
    // Password is correct, render the shortcode
    echo do_shortcode('[sdm_download id="####" fancy="1"]'); // WordPress shortcode
    }

    return ob_get_clean();
    }

    // Register the shortcode with WordPress
    add_shortcode('password_protected_download', 'password_protected_download_shortcode');
Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.