Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter ba95472

    (@ba95472)

    This looks right in the Purchase Receipt email and almost works but for some reason returns “Error 102: You do not have permission to download this file” even though the real URL *supposedly* is not altered? I’m stumped.

    function add_custom_edd_email_file_urls_tag() {
    // Register a new tag for file URLs with a custom function
    edd_add_email_tag(
    ‘custom_file_urls’,
    ‘Displays file download URLs with a randomized shortened link’,
    ‘custom_edd_email_file_urls’
    );
    }
    add_action(‘edd_add_email_tags’, ‘add_custom_edd_email_file_urls_tag’);

    function custom_edd_email_file_urls($payment_id) {
    $downloads = edd_get_payment_meta_downloads($payment_id);
    if ($downloads) {
    $file_urls = ”;
    foreach ($downloads as $download) {
    // Get the actual download URL using EDD’s default method
    $payment_data = edd_get_payment_meta($payment_id);
    $download_url = edd_get_download_file_url($payment_data[‘key’], $payment_data[’email’], $download[‘id’], 0);

            // Display the link with a visual representation of a shortened URL
            $random_string = substr(str_shuffle(md5(time())), 0, 6);
            $display_link_text = 'https://exam.pl/' . $random_string;
    
            $file_urls .= 'Download Link: <a href="' . $download_url . '">' . $display_link_text . '</a><br><br>';
        }
        return $file_urls;
    } else {
        return 'No downloadable files found.';
    }

    }

    Plugin Support Mihai Joldis

    (@misulicus)

    Hi there,

    Try the original link from EDD and see if that one works correctly. If that works then it’s possible that the shortened URL has the variables swapped after it’s being loaded?

    Thread Starter ba95472

    (@ba95472)

    Hi Mihai! Yes the original link works fine, that’s what’s odd since doing just a display mod of the actual URL *shouldn’t* affect how the link works, but unfortunately that’s what is happening. Thanks again!

    • This reply was modified 1 year ago by ba95472.
    Plugin Support Mihai Joldis

    (@misulicus)

    Please reach out to our team here https://easydigitaldownloads.com/support/ and we will take a closer look at things.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Link shortener?’ is closed to new replies.