Created
April 6, 2015 10:43
-
-
Save barrykooij/913a4f079fd38d80ecda to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* All downloads require visitors to be logged in | |
* | |
* @param $can_download | |
* @param $download | |
* | |
* @return bool | |
*/ | |
function vbmcauwemt_check_access( $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', 'vbmcauwemt_check_access', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is there any way to automatically check the "members only" checkbox, too?