Fatal error when adding "wpdm_allowed_roles" filter

Viewing 3 posts - 1 through 3 (of 3 total)
#70557

SOPG
Member

Hello,

with allowing file access for subscribers, we also want editors and administrators to be allowed to access that file, without adding both user roles to the “Allow access” field, too.

So we would like to modify the allowed roles array programmatically for the WPDM\libs\Apply::triggerDownload() function, but when we are trying to add a WP filter for the filter tag “wpdm_allowed_roles” (which gets applied in WPDM\Pakage::AllowedRoles($id), line 306), a fatal error occurs: “Fatal error: Maximum function nesting level of ‘100’ reached, aborting!”.

Example in functions.php:
add_filter(‘wpdm_allowed_roles’, ‘modifiyAllowedRoles’, 999, 2);
function modifyAllowedRoles($roles, $id) {
return $roles;
}

Is there another possibility to modify the allowed roles array programmatically for a triggered download?

Best regards
Michael

#70594

Hi,

With Advanced Access Control plugin you can select specific members to access the package. But as you want to hardcode the allow access roles, then please for custom upgrade send details to customize@wpdownloadmanager.com .

Thanks

#70641

SOPG
Member

Thank you for your fast reply,

and no, I don’t really wanna hardcode the allow access roles, I just want to add “editor” and “administrator” to the allow access roles for a file in PHP runtime, when “subscriber” is allowed to download that file. The reason is that from the hierarchical point of view, editors and administrators are allowed to do all things, a subscriber is allowed to do and we don’t wanna add all three roles (“subscriber”, “editor” and “administrator”) for each of our files.

Besides there is the apply_filter(‘wpdm_allowed_roles’, $id, $roles) command in WPDM\Pakage::AllowedRoles($id), line 306, which would be a really great solution for adding allowed access roles, based on the existing allowed access roles and perhaps other conditions 😉 But adding a “wpdm_allowed_roles” filter, using the WordPress built-in add_filter() function regretfully ends in a fatal error. 🙁

Thanks and best regards
Michael

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Fatal error when adding "wpdm_allowed_roles" filter’ is closed to new replies.