WordPress.org

Ready to get started?Download WordPress

Forums

Download Monitor
[resolved] Redirection filter if not 'Members' (3 posts)

  1. vdowsett
    Member
    Posted 10 months ago #

    For the website I'm working on only those who are logged in should be able to download items. If they are not logged in, I'd like to send them to a customer url to ask them to either log in or register.

    I'm trying to apply the filter to redirect users to the other url rather than the current download error page if they are not logged in. (just the login url for now, but a custom page later) I'm no expert, was hoping to get advice on the correct code to use in my functions file.

    $download_url = wp_login_url();
    $redirect = apply_filter( 'dlm_access_denied_redirect', true, $download_url );

    http://wordpress.org/plugins/download-monitor/

  2. Interpolat
    Member
    Posted 10 months ago #

    Use this in your functions.pho file:

    /** Downloads Monitor redirection to login page for non-logged in members trying to download content */
    
    function redirection() {
        $redirected_url = $_SERVER['HTTP_REFERER'];
        $download_url = $_SERVER['REQUEST_URI'];
        $download_redirect = urlencode("{$redirected_url}?redirect-to={$download_url}");
    
        return "YOUR_URL_HERE";
    
    }
    
    // filter calls
    
    add_filter(dlm_access_denied_redirect,'redirection');
  3. vdowsett
    Member
    Posted 9 months ago #

    Hi, that did the trick, thank you so much for your assistance!

Reply

You must log in to post.

About this Plugin

About this Topic