{"id":18512678,"date":"2025-06-15T00:35:32","date_gmt":"2025-06-15T00:35:32","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/edd-download-hook-edd_can_access_file-not-firing\/"},"modified":"2025-06-15T00:35:32","modified_gmt":"2025-06-15T00:35:32","slug":"edd-download-hook-edd_can_access_file-not-firing","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/edd-download-hook-edd_can_access_file-not-firing\/","title":{"rendered":"EDD Download Hook (edd_can_access_file) Not Firing"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">I&#8217;m encountering an issue where the edd_can_access_file filter isn&#8217;t firing as expected during Easy Digital Downloads file downloads, preventing my code from executing.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Environment:<\/strong><\/p>\n\n\n\n<ul>\n<li><strong>WordPress Version:<\/strong> 6.8.1<\/li>\n\n\n\n<li><strong>Easy Digital Downloads Version:<\/strong> 3.3.9 (Latest)<\/li>\n\n\n\n<li><strong>PHP Version:<\/strong> 8.4.4<\/li>\n\n\n\n<li><strong>Active Theme:<\/strong> Twenty Fifteen (no custom modifications)<\/li>\n\n\n\n<li><strong>Download Method:<\/strong> &#8220;Force Download&#8221; is enabled in EDD settings.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Code:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here&#8217;s the relevant part of my custom plugin code:<br \/><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function my_edd_restrict_download_after_expiration( $can_access, $download_id, $payment_id, $args ) {<br \/>    error_log( 'DEBUG: edd_can_access_file filter function WAS CALLED! Payment ID: ' . $payment_id );<br \/>    \/\/ Custom restriction logic should follow here, but this log is not output.<br \/>    return $can_access;<br \/>}<br \/>add_filter( 'edd_can_access_file', 'my_edd_restrict_download_after_expiration', 10, 4 );<br \/><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Observed Behavior &amp; Confirmed Checks:<\/strong><\/p>\n\n\n\n<ol>\n<li>My code loads correctly. A test log at the very beginning of the file (before any function definitions) <strong>is consistently output<\/strong>.<\/li>\n\n\n\n<li>The add_filter() call successfully registers my function to the edd_can_access_file filter. A debug log confirming this registration also <strong>is output<\/strong>.<\/li>\n\n\n\n<li>However, when a user attempts to download a file, the log line <strong>inside<\/strong> my_edd_restrict_download_after_expiration (DEBUG: edd_can_access_file filter function WAS CALLED!) is <strong>never output.<\/strong><\/li>\n\n\n\n<li>All common environmental factors have been excluded: no caching plugins, CDN, WAF, conflicting plugins\/themes, or fatal PHP errors (only deprecation warnings from EDD itself).<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Problem Summary:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Despite the function being correctly hooked to edd_can_access_file and the code loading successfully, the filter itself appears to <strong>not be firing<\/strong> during file download attempts. This behavior is unexpected, especially with &#8220;Force Download&#8221; enabled.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Any insights or potential solutions would be greatly appreciated.<\/p>\n","protected":false},"template":"","class_list":["post-18512678","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/18512678","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/18512678\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=18512678"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}