This guide assists administrators and developers in diagnosing and resolving common issues in the protected file access system.
Steps to resolve:
-
Open
secure-config.phpand check the role mappings:$role_mappings = [ 'subscriber' => 'group-1', 'contributor' => 'group-2' ];
-
Ensure the user has the correct role in WordPress.
-
Check directory permissions (at least 755 for folders, 644 for files).
-
If needed, consult the log file at:
secure-files/logs/access.log
Steps to resolve:
- Verify the URL (e.g.,
/protected/group-1/example-1.pdf). - Ensure the file exists in the correct group directory.
- Check if the file is correctly named and readable (permission 644).
Possible causes:
- Incorrect URL
- File in the wrong folder
- Incorrect
SECURE_FILE_PATHconstant
Solutions:
-
Compare the URL with the server structure:
/secure-files/group-1/example-1.pdf // for subscriber /secure-files/group-2/example-2.pdf // for contributor -
Check in
wp-config.php:define('SECURE_FILE_PATH', dirname(dirname(ABSPATH)) . '/secure-files');
-
Check for typos in the filename.
Possible causes:
- Missing or incorrect user role
- Role not registered in the access script
- File in the wrong directory
Solutions:
-
Check the user's role in WordPress.
-
Review the role configuration in
secure-config.php:$role_folders = [ 'subscriber' => 'group-1', 'contributor' => 'group-2' ];
-
Ensure the file and role match appropriately.
Possible causes:
- Cookie conflict between www/non-www
- Incorrect path to
wp-load.php - Invalid WordPress session
Solutions:
-
Check domain configuration in WordPress.
-
Verify in
check-access.php:require_once WP_CORE_PATH;
-
Clear browser cache and cookies.
Causes:
- PHP timeout exceeded
- Inappropriate chunk size
- Network issues / timeouts
Solutions:
-
Adjust
CHUNK_SIZEandMAX_DIRECT_DOWNLOAD_SIZEinsecure-config.php:define('CHUNK_SIZE', 4194304); // 4 MB define('MAX_DIRECT_DOWNLOAD_SIZE', 524288); // 512 KB
-
Check server timeout settings (
max_execution_time).
Symptoms:
- File opens in the browser instead of downloading
- Error: "unsupported format"
Solutions:
-
Add missing MIME types in
secure-config.php:$allowed_mime_types = [ 'pdf' => 'application/pdf', 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'html' => 'text/html' ];
-
Verify file extensions and type consistency.
Possible causes:
- Invalid PHP configuration
- Incorrect permissions
- Missing PHP extensions
Solutions:
-
Enable debug mode:
define('DEBUG_MODE', true);
-
Check permissions:
secure-files: 755 config: 755 secure-config.php: 644 -
Ensure required extensions (
fileinfo,mbstring,openssl) are active.
Causes:
- Chunk size too small
- High concurrent load
- Server resource limits
Solutions:
- Gradually increase
CHUNK_SIZE. - Use server-side rate limiting.
- Analyze server load (RAM, CPU, Disk I/O).
Symptoms:
- File changes not reflected
- Old versions shown in browser
Solutions:
-
Check cache-control settings:
define('CACHE_CONTROL', 'private, no-cache, no-store, must-revalidate');
-
Clear browser cache; disable caching plugins if necessary.
- Is the user logged in?
- Is the role configured correctly?
- Is the file in the correct group folder?
- Is the MIME type allowed?
- Are permissions set correctly?
- Is access being logged in
access.log?
For advanced diagnostics, regularly review the log file:
/secure-files/logs/access.log
This file contains information about blocked requests, access attempts, and error messages.