Forum Replies Created
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
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
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
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
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
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
Ok, glad to hear this , Please kindly let me know if you have any issues.
Thank you and kinmd regards
It’s name link-template-deafult, you can find it from Downloads > Templates > Link Templates, please kindly check.
Thank you and kind regards
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
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
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
Please kindly update the default value add-on to the latest version. please kindly check.
Thank you and kind regards
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,
Please kindly check.
Thank you again and regards
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
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
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
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
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
Please kindly share the related URL.
Thank you
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
Have you replied amy message here? Please kindly check.
Thank you and regards
Any meta-data you may include to tha packages, thus it maybe conflicting for updating default value. Please kindly check.
Thank you and regards
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