=== Member File Box – Secure Personal Downloads ===
Contributors: htonline
Tags: memberpress, private downloads, file delivery, secure files, user documents
Requires at least: 5.8
Tested up to: 6.9
Stable tag: 1.0.0
Requires PHP: 7.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Deliver individual PDF files to specific WordPress users. Each user sees only their own files. Use shortcode [ki_downloadbereich].

== Description ==

**Member File Box** lets you upload PDF files and assign them to individual WordPress users or MemberPress members. Each user can only access their own files — never those of other users.

Perfect for consultants, coaches, agencies, and service providers who need to deliver personalized documents such as reports, contracts, analyses, invoices, or handbooks directly to their clients through a secure member area.

= Key Features =

* **Individual file delivery** – Upload files and assign them to a specific user
* **Secure file storage** – Files are stored outside the public web root; direct URL access is blocked via `.htaccess`
* **Dedicated admin menu** – Manage all documents from a clean backend panel
* **Email notification** – Optionally notify the user by email when a new file is available
* **Expiry dates** – Set an optional expiry date per file; expired files are hidden automatically
* **Categories** – Organize files by type (Analysis, Contract, Handbook, Report, Checklist, etc.)
* **Frontend shortcode** – Display files to logged-in users with `[ki_downloadbereich]`
* **MemberPress compatible** – Works with any MemberPress version via direct database queries
* **Works without MemberPress** – Falls back to all WordPress users if MemberPress is not installed
* **Backend search** – Quickly filter documents by name, user, or category

= How It Works =

1. Admin uploads a PDF and selects a user from the dropdown
2. Optionally adds a description, category, expiry date, and enables email notification
3. The user logs in and sees their personal files via the `[ki_downloadbereich]` shortcode
4. Download links are validated server-side — only the assigned user (or admins) can download the file

= Use Cases =

* Deliver personalized compliance reports to individual clients
* Share contracts or invoices securely with specific users
* Provide custom analysis documents in a member area
* Send handbooks or onboarding materials to new members

= Shortcode =

Place this shortcode on any page in your member area:

`[ki_downloadbereich]`

Users who are not logged in will see a login prompt. Users with no assigned files will see an informative empty state message.

== Installation ==

1. Upload the `member-file-box` folder to `/wp-content/plugins/`
2. Activate the plugin through the **Plugins** menu in WordPress
3. Go to **KI Documents** in your admin sidebar to upload files
4. Add the shortcode `[ki_downloadbereich]` to the page where users should see their files
5. (Optional) Protect that page using a MemberPress access rule or WordPress capability

== Frequently Asked Questions ==

= Does this plugin work without MemberPress? =

Yes. Without MemberPress, the user dropdown shows all WordPress users and any logged-in user can access their assigned files. MemberPress is recommended for membership-based access control, but not required.

= Where are the uploaded files stored? =

Files are stored in `/wp-content/ki-dokumente-secure/`. This directory is protected by a `.htaccess` rule that blocks all direct HTTP access. Files are only served through a validated WordPress download handler.

= Can one user see another user's files? =

No. Every download request is validated server-side. Only the assigned user (or a WordPress administrator) can download a file.

= What file types are supported? =

Currently only PDF files are supported (max. 50 MB per file).

= Can I set an expiry date for a file? =

Yes. You can optionally set an expiry date per file during upload. After that date the file is automatically hidden from the user's download area.

= How do I notify a user about a new file? =

Check the "Notify member by email" checkbox when uploading. The plugin sends an HTML email via `wp_mail()` using your site's configured mail settings (e.g. WP Mail SMTP).

= Can administrators download all files? =

Yes. WordPress administrators bypass the access check and can download any file at any time.

= How do I display the file area on my site? =

Add the shortcode `[ki_downloadbereich]` to any page. We recommend placing it inside a MemberPress-protected page or a page restricted by user role so only authorized users can access it.

== Screenshots ==

1. Backend upload form — assign a file to a specific user with category, expiry date and email notification
2. Backend document list with search and delete functionality
3. Frontend download area showing the logged-in user's personal files

== Changelog ==

= 1.0.0 =
* Initial release
* Individual file upload and assignment per user
* Secure file storage outside the public web root (.htaccess protection)
* MemberPress integration via direct DB query (version-independent)
* Fallback mode for sites without MemberPress
* Optional email notification on new file
* Expiry date support per file
* Categories: Analysis, Contract, Handbook, Report, Checklist, and more
* Shortcode [ki_downloadbereich] for frontend display
* Backend search across all documents
* Clean admin interface with upload form and document list

== Upgrade Notice ==

= 1.0.0 =
Initial release — no upgrade needed.
