Nayeem Riddhi

Forum Replies Created

Viewing 25 posts - 1,276 through 1,300 (of 20,382 total)
May 23, 2025 at 9:35 am
#206693
Moderator
Nayeem Riddhi
Staff OP

Here are the ways to override these functions in your theme’s functions.php:

# Simple WPDM Function Override in functions.php

Here are the ways to override these functions in your theme’s functions.php:

## Method 1: Direct Function Override (Recommended)


// Add to your theme's functions.php

// Override wpdm_user_has_access function
if (!function_exists('wpdm_user_has_access')) {
    function wpdm_user_has_access($id, $type = 'package') {
        $current_user = wp_get_current_user();
        
        if (!$id) {
            return false;
        }
        
        // Get allowed roles
        if ($type == 'package') {
            $roles = wpdm_allowed_roles($id);
        } else {
            // For categories - you may need to adjust this
            $roles = get_term_meta($id, '__wpdm_access', true);
            $roles = maybe_unserialize($roles);
        }

        if (!is_array($roles)) {
            $roles = array();
        }
        
        $matched = is_user_logged_in() ? array_intersect($current_user->roles, $roles) : array();

        // Check access conditions
        if ($type === 'category' && count($roles) == 0) {
            return true;
        }
        if (in_array('guest', $roles)) {
            return true;
        }
        if (count($matched) > 0) {
            return true;
        }

        return false;
    }
}

// Override wpdm_allowed_roles function
if (!function_exists('wpdm_allowed_roles')) {
    function wpdm_allowed_roles($id) {
        $roles = get_post_meta($id, '__wpdm_access', true);
        $roles = maybe_unserialize($roles);

        $cats = get_the_terms($id, 'wpdmcategory');
        if (!is_array($roles)) {
            $roles = array();
        }
        
        if (is_array($cats)) {
            foreach ($cats as $cat) {
                $croles = get_term_meta($cat->term_id, '__wpdm_access', true);
                $croles = maybe_unserialize($croles);
                if (is_array($croles)) {
                    $roles = array_merge($roles, $croles);
                }
            }
        }

        $roles = array_unique($roles);
        $roles = apply_filters("wpdm_allowed_roles", $roles, $id);
        
        if (!is_array($roles)) {
            $roles = array();
        }

        return $roles;
    }
}

## Method 2: Create Custom Versions


// Custom versions with your own names
function my_wpdm_user_has_access($id, $type = 'package') {
    // Your custom logic here
    $current_user = wp_get_current_user();
    
    if (!$id) return false;
    
    $roles = my_wpdm_allowed_roles($id);
    if (!is_array($roles)) $roles = array();
    
    $matched = is_user_logged_in() ? array_intersect($current_user->roles, $roles) : array();
    
    if (in_array('guest', $roles) || count($matched) > 0) {
        return true;
    }
    
    return false;
}

function my_wpdm_allowed_roles($id) {
    $roles = get_post_meta($id, '__wpdm_access', true);
    $roles = maybe_unserialize($roles);
    
    if (!is_array($roles)) {
        $roles = array();
    }
    
    // Apply your custom logic here
    $roles = apply_filters("my_wpdm_allowed_roles", $roles, $id);
    
    return $roles;
}

## Method 3: Using Filters to Modify Behavior


// Modify the allowed roles using existing filter
function modify_wpdm_allowed_roles($roles, $package_id) {
    // Add custom logic
    // Example: Always allow administrators
    if (!in_array('administrator', $roles)) {
        $roles[] = 'administrator';
    }
    
    // Example: Remove guest access for specific packages
    if ($package_id == 123 && in_array('guest', $roles)) {
        $roles = array_diff($roles, array('guest'));
    }
    
    return $roles;
}
add_filter('wpdm_allowed_roles', 'modify_wpdm_allowed_roles', 10, 2);

// Create custom access check filter
function custom_wpdm_access_check($has_access, $package_id, $user_id = null) {
    if ($user_id === null) {
        $user_id = get_current_user_id();
    }
    
    // Your custom access logic
    // Example: VIP users always have access
    if (user_can($user_id, 'vip_access')) {
        return true;
    }
    
    return $has_access;
}
// Apply this filter in your custom function

## Method 4: Wrapper Functions (Safest)


// Safe wrapper functions that fallback to originals
function safe_wpdm_user_has_access($id, $type = 'package') {
    // Try original function first
    if (function_exists('wpdm_user_has_access') && class_exists('WPDM')) {
        return wpdm_user_has_access($id, $type);
    }
    
    // Fallback logic
    return my_wpdm_user_has_access($id, $type);
}

function safe_wpdm_allowed_roles($id) {
    // Try original function first
    if (function_exists('wpdm_allowed_roles') && class_exists('WPDM')) {
        return wpdm_allowed_roles($id);
    }
    
    // Fallback logic
    return my_wpdm_allowed_roles($id);
}

## Usage Examples


// In your theme templates or other functions
if (safe_wpdm_user_has_access(123)) {
    echo "User has access to package 123";
}

$allowed_roles = safe_wpdm_allowed_roles(123);
if (in_array('subscriber', $allowed_roles)) {
    echo "Subscribers can access this package";
}

## Key Points:

– **Method 1** completely replaces the original functions
– **Method 2** creates parallel functions you control
– **Method 3** uses filters to modify existing behavior
– **Method 4** provides safe fallbacks

Choose the method that best fits your needs. Method 4 is recommended for production use as it’s the safest approach. Please kindly check.

Thank you and regards

May 23, 2025 at 8:32 am
#206691
Moderator
Nayeem Riddhi
Staff OP

Can you please let me know which fumction/hook you have adjusted thus I can check if there any possibility for keeping backup for next update. Please kindly check.

Thank you and kind regards

May 23, 2025 at 8:30 am
#206690
Moderator
Nayeem Riddhi
Staff OP

I think this is a server issue. You can directly contact with your server administrator too for your issue. Please kindly check.

Thank you and kind regards

May 23, 2025 at 6:16 am
#206686
Moderator
Nayeem Riddhi
Staff OP

Hello Jakub Jurgiel,

Hope you are well. Can you please kindly let me know which appearance or features you want to extend? Please kindly check.

Thank you and kind regards

May 23, 2025 at 4:44 am
#206684
Moderator
Nayeem Riddhi
Staff OP

For cancelling auto-renew please send an order note from this Page by following This. Also, please let us know which feature we can add/improve or support we can give you. Please check and let me know if you have any queries.

Thank you and kind regards

May 23, 2025 at 4:43 am
#206683
Moderator
Nayeem Riddhi
Staff OP

Hello Tham Hoang,

Hope you are well. And sorry for the inconvenience. if possible, can you please, give your temporary wp-admin login details in a private reply to check the issue?

Thank you and regards

May 23, 2025 at 4:40 am
#206682
Moderator
Nayeem Riddhi
Staff OP

Hello Kees Krul,

Hope you are well. And sorry for the inconvenience. Please kindly share the related URLs. if possible, please, give your temporary wp-admin login details in a private reply to check the issue.

Thank you and regards

May 22, 2025 at 12:12 pm
#206672
Moderator
Nayeem Riddhi
Staff OP

Hello Denis Beliajevas,

Hope you are well. For cancelling auto-renew please send an order note from this Page by following This. Also, please let us know which feature we can add/improve or support we can give you. Please check and let me know if you have any queries.

Thank you and kind regards

May 22, 2025 at 8:28 am
#206669
Moderator
Nayeem Riddhi
Staff OP

Ok, glad to hear this , Please kindly let me know if you have any issues.

Thank you and kinmd regards

May 22, 2025 at 6:35 am
#206666
Moderator
Nayeem Riddhi
Staff OP

It’s name link-template-deafult, you can find it from Downloads > Templates > Link Templates, please kindly check.

Thank you and kind regards

May 22, 2025 at 6:24 am
#206663
Moderator
Nayeem Riddhi
Staff OP

With [wpdm_packages] shortcode you are capable to use custom link-template for appearance. It has also a parameter callied template, Please kindly check.

Thank you and kind regards

May 22, 2025 at 6:09 am
#206661
Moderator
Nayeem Riddhi
Staff OP

Glad to hear that. However, if you need further help with anything else, then please don’t hesitate to open a new topic. If you get some free moments, can you please give us a 5* here https://wordpress.org/support/plugin/download-manager/reviews/?rate=5#new-post, It will inspire us a lot. Thanks in advance…

Thank you again and regards

May 21, 2025 at 11:49 pm
#206658
Moderator
Nayeem Riddhi
Staff OP

Glad to hear that. However, if you need further help with anything else, then please don’t hesitate to open a new topic. If you get some free moments, can you please give us a 5* here https://wordpress.org/support/plugin/download-manager/reviews/?rate=5#new-post, It will inspire us a lot. Thanks in advance…

Thank you again and regards

May 21, 2025 at 1:33 pm
#206656
Moderator
Nayeem Riddhi
Staff OP

Please kindly update the default value add-on to the latest version. please kindly check.

Thank you and kind regards

May 21, 2025 at 4:19 am
#206636
Moderator
Nayeem Riddhi
Staff OP

Hello Pranav Deobhakta,

Hope you are well. Thanks for writing to us. wpdm_all_packages shortcode may have not the scope entirely with your requiremets, but you can check this shortcode too for your requirement,

https://www.wpdownloadmanager.com/doc/short-codes/wpdm_packages-wp_query-in-a-shortcode-for-download-manager-packages/

Please kindly check.

Thank you again and regards

May 21, 2025 at 4:09 am
#206635
Moderator
Nayeem Riddhi
Staff OP

Sorry for the inconveneince. We are checking the issue. I have already forwarded it to our related team authority regarding the issue. Please kindly check and let me know if you have any more queries.

Thank you and kind regards

May 20, 2025 at 11:35 pm
#206632
Moderator
Nayeem Riddhi
Staff OP

Hello Steven,

Hope you are well. And sorry for the inconvenience. Can you please share the order id details thus I can forward it to our related team authority for the issue. Please kindly check and let me know.

Thank you and kind regards

May 20, 2025 at 5:46 pm
#206628
Moderator
Nayeem Riddhi
Staff OP

It may have a conflict between your plugins or theme too. Am i able disable one by one other plugins for testing if there any conflicts. I can also switch theme to another for checking. Please kindly check and let me know.

Thank you and kind regards

May 20, 2025 at 10:19 am
#206613
Moderator
Nayeem Riddhi
Staff OP

I have checked the Flyer section download, it seems that the download is working properly as expected for those packages. Please kindly check and let me know.

Thank you and kind regards

May 20, 2025 at 8:23 am
#206610
Moderator
Nayeem Riddhi
Staff OP

I have back information from our team authority that, please kindly wait 24 hour for your issue. I hope within this time the issue maybe get resolved. Please kindly check.

Thank you and regards

May 20, 2025 at 8:18 am
#206609
Moderator
Nayeem Riddhi
Staff OP

Please kindly share the related URL.

Thank you

May 20, 2025 at 7:08 am
#206606
Moderator
Nayeem Riddhi
Staff OP

Please kindly have patience. I have information from our team that, you may receive a response within this week. We are sorry for the delay.

Thank you and kind regards

May 20, 2025 at 5:29 am
#206604
Moderator
Nayeem Riddhi
Staff OP

Have you replied amy message here? Please kindly check.

Thank you and regards

May 20, 2025 at 5:28 am
#206603
Moderator
Nayeem Riddhi
Staff OP

Any meta-data you may include to tha packages, thus it maybe conflicting for updating default value. Please kindly check.

Thank you and regards

May 20, 2025 at 4:49 am
#206602
Moderator
Nayeem Riddhi
Staff OP

Glad to hear that. However, if you need further help with anything else, then please don’t hesitate to open a new topic. If you get some free moments, can you please give us a 5* here https://wordpress.org/support/plugin/download-manager/reviews/?rate=5#new-post, It will inspire us a lot. Thanks in advance…

Thank you again and regards

Viewing 25 posts - 1,276 through 1,300 (of 20,382 total)