Title: Link shortener?
Last modified: November 25, 2023

---

# Link shortener?

 *  Resolved [ba95472](https://wordpress.org/support/users/ba95472/)
 * (@ba95472)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/link-shortner/)
 * Is there a way to shorten the display part of the download link in the Purchase
   Receipt email (actual long URL still intact)? For example:
 * Product: Sample Book.pdf
   Download Link: [https://exam.pl](https://example.com/index.php?eddfile=7%3A882%3A1&ttl=1701030597&file=1&token=8b7c125ec125a7706d64a208106d40a0517d140e9ea2c04ca21c71e8b619ca5e)/
   [19ca5e](https://example.com/index.php?eddfile=7%3A882%3A1&ttl=1701030597&file=1&token=8b7c125ec125a7706d64a208106d40a0517d140e9ea2c04ca21c71e8b619ca5e)
 * (instead of this)
 * Product: Sample Book.pdf
   Download Link: [https://example.com/index.php?eddfile=7%3A882%3A1&ttl=1701030597&file=1&token=8b7c125ec125a7706d64a208106d40a0517d140e9ea2c04ca21c71e8b619ca5e](https://example.com/index.php?eddfile=7%3A882%3A1&ttl=1701030597&file=1&token=8b7c125ec125a7706d64a208106d40a0517d140e9ea2c04ca21c71e8b619ca5e)
 * ####
   Product: {product_titles}Download Link: {file_urls}
    -  This topic was modified 2 years, 8 months ago by [ba95472](https://wordpress.org/support/users/ba95472/).
    -  This topic was modified 2 years, 8 months ago by [ba95472](https://wordpress.org/support/users/ba95472/).
    -  This topic was modified 2 years, 8 months ago by [ba95472](https://wordpress.org/support/users/ba95472/).

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Thread Starter [ba95472](https://wordpress.org/support/users/ba95472/)
 * (@ba95472)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/link-shortner/#post-17230887)
 * 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 functionedd_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);
 *     ```wp-block-code
               // 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 Contributor [Mihai Joldis](https://wordpress.org/support/users/misulicus/)
 * (@misulicus)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/link-shortner/#post-17232042)
 * 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](https://wordpress.org/support/users/ba95472/)
 * (@ba95472)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/link-shortner/#post-17232064)
 * 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 2 years, 8 months ago by [ba95472](https://wordpress.org/support/users/ba95472/).
 *  Plugin Contributor [Mihai Joldis](https://wordpress.org/support/users/misulicus/)
 * (@misulicus)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/link-shortner/#post-17232101)
 * Please reach out to our team here [https://easydigitaldownloads.com/support/](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.

 * ![](https://ps.w.org/easy-digital-downloads/assets/icon.svg?rev=3455837)
 * [Easy Digital Downloads – eCommerce Payments and Subscriptions made easy](https://wordpress.org/plugins/easy-digital-downloads/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/easy-digital-downloads/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/easy-digital-downloads/)
 * [Active Topics](https://wordpress.org/support/plugin/easy-digital-downloads/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/easy-digital-downloads/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/easy-digital-downloads/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [Mihai Joldis](https://wordpress.org/support/users/misulicus/)
 * Last activity: [2 years, 8 months ago](https://wordpress.org/support/topic/link-shortner/#post-17232101)
 * Status: resolved