Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #21106
    xchristox
    Participant

    Hi All,

    The Download attachment plugin is awesome. it’s the best out there.

    But lately I have been struggling to keep my website online, the GB’s of bandwidth download traffic seems to have exploded but I don’t see the visitors on my website. I changed the download links a few times, which stopped it for a while, but after a day or two it starts again. I have the feeling other websites are deep/direct linking to the files and I don’t know how to stop it.

    It would be OK if the attachments (PDF’s) were loaded on a website page first, then at least I have the visitor counted. Right now, I am only paying bandwidth for others to deep/direct link to.

    Can you help me? What are my options to protect my bandwidth traffic?

    #21107
    Bartosz
    Keymaster

    Hi,

    And thanks for the kind words.

    One of the solutions for this is to prevent downloading for logged-out users.

    Like this:

    function custom_da_download_attachment_id( $id ) {
    	if ( ! is_user_logged_in() ) {
    		wp_redirect( home_url() ); exit;
    	}
    	return $id;
    }
    add_action( 'da_download_attachment_id', 'custom_da_download_attachment_id' );
    #21109
    xchristox
    Participant

    Thanks :) That would work, but where do I add the code exactly?

    #21110
    xchristox
    Participant

    I made it work but people simply end up to my homepage, no info given.

    Can I amend the code to re-direct to a specific page, where I explain that users need to be logged in for downloads?

    function custom_da_download_attachment_id( $id ) {
    if ( ! is_user_logged_in() ) {
    wp_redirect( home_url() ); exit;
    }
    return $id;
    }
    add_action( ‘da_download_attachment_id’, ‘custom_da_download_attachment_id’ );

    #21111
    Bartosz
    Keymaster

    Just add this to functions.php file of your theme or via any code snippet plugin you use.

    And of course you can redirect users anywhere you like.

    wp_redirect( get_permalink( 6 ) ); exit;

    where 6 is the id of the page

    #24353
    haicu
    Participant

    Hi, I used this code to prevent downloading the attachment. It is working fine for the plugin download links.
    If somebody somehow guesses the regular download link from the document in the media library it is still accessible without logging in.
    Is there a way to prevent that?

    Thank you,

    Han

    #24367
    Bartosz
    Keymaster

    Han, try using Encrypt Urls option – this will be hard to guess : )

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.