• Resolved chrisisluis

    (@chrisisluis)


    Any support for automatically classifying uploaded content under the “Members only” tab on upload, rather than manually updating file permissions after uploading?

Viewing 1 replies (of 1 total)
  • Hey Chris,

    To make all downloads members only, you will need to add below code to 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;
    	} else if ( is_multisite() && ! is_user_member_of_blog( get_current_user_id(), get_current_blog_id() ) ) {
    		// Check if it's a multisite and if user is member of blog
    		$can_download = false;
    	}
    
    	return $can_download;
    }

    I hope that resolves the issue. Let us know if you require any further assistance.

Viewing 1 replies (of 1 total)
  • The topic ‘Set Default Permissions on Upload’ is closed to new replies.