• Resolved simusch

    (@simusch)


    Hi

    I try to set up a website where only registered users can download files (but all users should see all downloadable files)

    i set all files to “member only”

    this works well.

    but when i click on a link, i get this message:
    “You do not have permission to access this download”

    is there some possibility to lead to a register/login page here?
    this would be great!

    simon

    https://www.ads-software.com/plugins/download-monitor/

Viewing 6 replies - 1 through 6 (of 6 total)
  • There sure is. You can redirect users to a custom URL using the dlm_access_denied_redirect filter. Whenever that filters returns an URL the user is redirected instead of shown the error message.

    i used this code AND ADED TO function.php OF MY THEME , also changed the url but didn’t work?

    https://gist.github.com/jordanthornquest/6184806

    Thread Starter simusch

    (@simusch)

    thanks!

    I missed the filters section in the documentation, sorry!
    I managed it, to redirect to a register-page on a WPML-installation. this function now searches for the register-page in the current language:

    function download_access_denied() {
    		global $wpdb;
    
    		//get link to register-page
    		$id = $wpdb->get_var("SELECT ID FROM ".$wpdb->posts." WHERE post_name = 'register'");
    		    if(function_exists('icl_object_id')){
    		        return get_permalink(icl_object_id($id,'page',true));
    		    }
    	}
    	add_filter('dlm_access_denied_redirect', 'download_access_denied');

    i have multisite wordpress, add this code to function.php of my theme but didn’t work
    any body have more good code?

    Hi simsch.
    Im new to this.
    Can you explain about filters and how to do what you have done?
    Thanks.

    Just add it at the end of: download-monitor/includes/download-functions.php

    add_filter( 'dlm_access_denied_redirect', 'my_access_denied_redirect' );
    
    function my_access_denied_redirect() {
    return "https://YourURL.com";
    }

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Catch the "You do not have permission to access this download" message’ is closed to new replies.