logo
Ask your WordPress questions! Pay money and get answers fast! (more info)

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.

$50
How to redirect to new page after download file has initiated?

Hi,
I run a site which gives away psd graphics as freebies. After the visitor has clicked the download link I want the page to redirect to a "thank you for downloading" page.

I now this is not a straight up WordPress inquiry but still, can anyone help me with this?

Orman over at Premiumpixels.com uses a method that seems cool.

This question has been answered.

LeTune | 11/28/11 at 4:19am Edit


(7) Possible Answers Submitted...

See a chronological view of answers?

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

  • avatar
    Last edited:
    11/28/11
    5:00am
    Gabriel Reguly says:

    Hi LeTune,

    Use a meta tag.

    <meta http-equiv="refresh" content="5; url=http://example.com/">

    http://en.wikipedia.org/wiki/Meta_refresh


    Regards
    Gabriel

    -- Edit: John Cotton gave a good answer, here is the link to the jQuery code http://turbo.premiumpixels.com/wp-content/themes/premium/js/jquery.download.js?ver=3.2.1

    Maybe this code is not GPL, you should check it before using the code.

    Previous versions of this answer: 11/28/11 at 4:22am | 11/28/11 at 5:00am

  • avatar
    Last edited:
    11/28/11
    4:22am
    Ali Hussain says:

    Do you use any plugin or is it that you place a download link directly?

  • avatar
    Last edited:
    11/28/11
    4:23am
    Julio Potier says:

    Hello

    What kind of code are you using for the download link ?
    Ajax mode ? or "just" click-to-get mode ?

    See you soon

  • avatar
    Last edited:
    11/28/11
    4:24am
    Ryan Riatno says:

    You can use plugin to do that here's some:
    http://wordpress.org/extend/plugins/download-monitor/
    http://wordpress.org/extend/plugins/wp-downloadmanager/

    There's option to redirect to a new page after user click download

  • avatar
    Last edited:
    11/28/11
    4:37am
    Hai Bui says:

    Premiumpixels.com use javascript/jQuery to do it. I can create the same function for you, but it only works if you insert the download links manually. PM me if you are interested.

    • 11/28/11 7:29am

      LeTune says:

      Hi Hai,
      I add download links via custom field, manually for every post. Send me an email at hello@premiumpsd.com

  • avatar
    Last edited:
    11/28/11
    4:55am
    John Cotton says:

    PremiumPixels is using this javascript to do it:


    jQuery(function () {

    // get the GET variables
    var theme = getUrlVars();

    var downloadLink = 'http://cdn.premiumpixels.com/uploads/' + theme['file'] + '.zip';

    if(theme['file'])
    {
    jQuery('#downloadLink').attr('href', downloadLink);

    delayedDownload();
    }

    function delayedDownload()
    {
    timeoutID = window.setTimeout(downloadTheme, 1000);
    }

    function downloadTheme()
    {
    window.location.replace(downloadLink);
    //window.open(downloadLink,'','menubar=1,location=1,toolbar=1,width=600,height=500');
    }

    // Read a page's GET URL variables and return them as an associative array.
    function getUrlVars()
    {
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');

    for(var i = 0; i < hashes.length; i++)
    {
    hash = hashes[i].split('=');
    vars.push(hash[0]);
    vars[hash[0]] = hash[1];
    }

    return vars;
    }

    });


    So his link to the file is actually a link to another page with a query string variable (in this case, the name of the download file without .zip on it.

    ie http://www.premiumpixels.com/download/?file=menu

    What you are seeing is the contents of /download - try without the ?file=menu on the end....!

    So the user clicks through to the next page (which could be anything of course - you could easily have some logic in there that detected the actual file being downloaded and change the contents of the page based on that) and then the script above fires off, reads the query string and downloads the file!

    Previous versions of this answer: 11/28/11 at 4:55am

    • 11/28/11 5:47am

      LeTune says:

      Hi John, could you help me implement this?

      Send an email to hello@premiumpsd.com

  • avatar
    Last edited:
    11/28/11
    4:49am
    Arnav Joy says:

    Try to run the code of downloading in the thanks page itself.
    I have done it something similar in http://www.webgranth.com/ebook-tutorial
    if it is uerfull to you then you can contact me at
    robingupta0512@gmail.com

This question has expired.



Gabriel Reguly, LeTune, Julio Potier, Francisco Javier Carazo Gil voted on this question.



Current status of this question: Completed



Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.