• Resolved ProxxiM

    (@proxxim)


    Hi there,

    I want to use Download Monitor for protecting files, but when inserting a new download in a post, I don’t get the option to protect this new file.

    Isn’t there a possibility to add an option in this screen (when editing a post), to enable the download only for members?

    Do I really have to go to the separate download section to enable the protection per file?

    An option to enable protection for all files by default would be OK as well, I guess.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello,

    While there is no option to make a download “Members Only” from the post page, you can make all downloads “Members Only” by adding below code to the end of the “functions.php” file located inside your active theme folder.

    /**
     * All downloads require visitors to be logged in
     *
     * @param $can_download
     * @param $download
     *
     * @return bool
     */
    function dlm_all_downloads_members_only( $can_download, $download ) {
    
    	// No need for checking if access is already denied
    	if ( false == $can_download ) {
    		return $can_download;
    	}
    
    	// Check if user is logged in
    	if ( ! is_user_logged_in() ) {
    		$can_download = false;
    	} // Check if it's a multisite and if user is member of blog
    	else if ( is_multisite() && ! is_user_member_of_blog( get_current_user_id(), get_current_blog_id() ) ) {
    		$can_download = false;
    	}
    
    	return $can_download;
    }
    
    add_filter( 'dlm_can_download', 'dlm_all_downloads_members_only', 10, 2 );

    I hope that answers your query. Let us know if you have any further questions.

    Thread Starter ProxxiM

    (@proxxim)

    Harish, thank you for taking the time to answer my question, this seems to solve my problem. Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Protect files by default or option’ is closed to new replies.