Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ### \download-monitor\src\DownloadHandler.php
- ###
- ###
- ### BEFORE
- ###
- ###
- public function check_members_only( $can_download, $download ) {
- // Check if download is a 'members only' download
- if ( false !== $can_download && $download->is_members_only() ) {
- // 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;
- }
- ###
- ###
- ### AFTER
- ###
- ###
- public function check_members_only( $can_download, $download ) {
- // Check if download is a 'members only' download
- if ( false !== $can_download && $download->is_members_only() ) {
- // 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;
- }
- else if ( !current_user_can('editor') && !current_user_can('administrator') ) {
- global $wpdb;
- $current_user = wp_get_current_user();
- $table = $wpdb->prefix . "swpm_members_tbl";
- $sql = "SELECT `account_state` FROM `{$table}` WHERE email = \"%s\";";
- $res = $wpdb->get_var( $wpdb->prepare( $sql, $current_user->user_email ) );
- if ($res != "active") header("Location: /access-renewal/");
- }
- }
- return $can_download;
- }
Advertisement
Add Comment
Please, Sign In to add comment