A ProcessWire module to manage lead magnets, capture email addresses, and securely deliver files via temporary download links.
- Automated Form Handling: Automatically intercepts form submissions before the page is rendered.
- Secure File Delivery: Generates unique, temporary download tokens (valid for 24 hours) to prevent direct file access.
- Email Automation: Sends an email to the subscriber with the secure download link.
- Double Opt-In (DOI): Optional requirement for users to confirm their email before receiving the download.
- File Attachments: Option to attach the file directly to the email instead of sending a link.
- AJAX Submission: Seamless form experience using Alpine.js (configurable).
- Lead Archiving: Stores subscriber details (Email, Magnet ID, IP, Timestamp) in a custom database table (
leads_archive). - System Logging: Logs new leads to the ProcessWire system logs (
leads). - Admin Interface: Dedicated page under Setup > Lead Magnets to view and manage leads.
- CSV Export: Export all captured leads to a CSV file via the admin interface.
- CSRF Protection: Built-in security for form submissions.
- Default Styling: Includes basic CSS for the form (responsive and clean).
- Translatable: All frontend and backend texts are translatable.
- Easy Integration: Render the subscription form with a single method call.
- Copy the
LeadMagnetManagerfolder into yoursite/modules/directory. - Login to the ProcessWire Admin.
- Go to Modules > Refresh.
- Click Install next to "WireMagnet".
You can configure the module settings directly in the ProcessWire Admin (Modules > Site > Lead Magnet Manager > Configure):
- Sender Email Address: The email address the download emails are sent from (default:
noreply@yoursite.com). - Email Subject: The subject line of the download email.
- Enable Double Opt-In (DOI): If enabled, users must confirm their email address via a link sent to them before they receive the final download email.
- Attach File to Email: If enabled, the file is attached directly to the email. Note: Large files might be rejected by mail servers.
- Load Alpine.js: If enabled, the module loads Alpine.js from a CDN to handle AJAX form submissions. Uncheck this if you already include Alpine.js in your site.
- Form Button Text: Customize the text on the submit button (default: "Get Free Download").
- The module automatically creates a template named lead-magnet and a field named lead_file.
- Create a new Page using the
lead-magnettemplate. - Upload your file (PDF, Zip, etc.) to the
lead_filefield on that page.
Note: You can also use any other template and file field. Just make sure to pass the field name to the render method (see below).
In your template file (e.g., lead-magnet.php), use the following code to render the subscription form:
<?php
// Render the subscription form (default field: 'lead_file')
// The module automatically handles success/error messages and styling.
echo $modules->get('WireMagnet')->renderForm($page);
// OR: Render for a specific field (e.g., if you have multiple magnets or custom field names)
// echo $modules->get('WireMagnet')->renderForm($page, 'my_custom_file_field');
// OR: Override the button text manually
// echo $modules->get('WireMagnet')->renderForm($page, 'lead_file', 'Send me the PDF!');
?>- The user enters their email address.
- The module intercepts the POST request.
- The lead is saved to the
leads_archivedatabase table. - A unique token is generated and stored in
lead_tokens. - An email is sent to the user with a link like
https://yoursite.com/lead-download/{token}. - When clicked, the module validates the token and expiry (24h) and serves the file securely using
wireSendFile().
The module automatically creates two tables:
leads_archive: Stores the history of all leads.lead_tokens: Stores active download tokens and their expiry times.
Markus Thomas