Overview
WordPress Download Manager uses a combination of WordPress core tables (posts, postmeta, terms) and custom tables for specialized data storage. This reference documents all database structures.
Table Prefix
All custom tables use the WordPress table prefix followed by ahm_:
{$wpdb->prefix}ahm_table_name
Example: wp_ahm_download_stats
Custom Tables
ahm_download_stats
Stores download tracking data.
CREATE TABLE {prefix}ahm_download_stats (
id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
pid BIGINT(20) UNSIGNED NOT NULL,
uid BIGINT(20) UNSIGNED DEFAULT 0,
oid VARCHAR(50) DEFAULT NULL,
year SMALLINT(4) UNSIGNED NOT NULL,
month TINYINT(2) UNSIGNED NOT NULL,
day TINYINT(2) UNSIGNED NOT NULL,
timestamp INT(11) UNSIGNED NOT NULL,
ip VARCHAR(45) DEFAULT NULL,
agent TEXT,
country VARCHAR(2) DEFAULT NULL,
city VARCHAR(100) DEFAULT NULL,
filename VARCHAR(255) DEFAULT NULL,
version VARCHAR(50) DEFAULT NULL,
PRIMARY KEY (id),
KEY pid (pid),
KEY uid (uid),
KEY timestamp (timestamp),
KEY year_month_day (year, month, day)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
| Column | Type | Description |
|---|---|---|
id |
BIGINT | Auto-increment primary key |
pid |
BIGINT | Package post ID |
uid |
BIGINT | User ID (0 for guests) |
oid |
VARCHAR(50) | Order ID (for paid downloads) |
year |
SMALLINT | Download year |
month |
TINYINT | Download month |
day |
TINYINT | Download day |
timestamp |
INT | Unix timestamp |
ip |
VARCHAR(45) | IP address (IPv4/IPv6) |
agent |
TEXT | User agent string |
country |
VARCHAR(2) | Country code |
city |
VARCHAR(100) | City name |
filename |
VARCHAR(255) | Downloaded file name |
version |
VARCHAR(50) | Package version at download |
Indexes:
pid– Package lookupsuid– User download historytimestamp– Date range queriesyear_month_day– Daily statistics
ahm_emails
Stores email lock subscriber data.
CREATE TABLE {prefix}ahm_emails (
id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
email VARCHAR(100) NOT NULL,
pid BIGINT(20) UNSIGNED NOT NULL,
date DATETIME NOT NULL,
custom_data TEXT,
ip VARCHAR(45) DEFAULT NULL,
verified TINYINT(1) DEFAULT 0,
PRIMARY KEY (id),
UNIQUE KEY email_pid (email, pid),
KEY pid (pid),
KEY date (date)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
| Column | Type | Description |
|---|---|---|
id |
BIGINT | Auto-increment primary key |
email |
VARCHAR(100) | Subscriber email |
pid |
BIGINT | Package post ID |
date |
DATETIME | Submission date |
custom_data |
TEXT | JSON additional form data |
ip |
VARCHAR(45) | Submitter IP |
verified |
TINYINT | Email verified flag |
ahm_social_conns
Stores social login/lock data.
CREATE TABLE {prefix}ahm_social_conns (
id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
pid BIGINT(20) UNSIGNED NOT NULL,
email VARCHAR(100) DEFAULT NULL,
source VARCHAR(20) NOT NULL,
social_id VARCHAR(100) DEFAULT NULL,
name VARCHAR(100) DEFAULT NULL,
access_token TEXT,
data TEXT,
date DATETIME NOT NULL,
PRIMARY KEY (id),
KEY pid_source (pid, source),
KEY email (email)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
| Column | Type | Description |
|---|---|---|
source |
VARCHAR(20) | Platform (linkedin, twitter, facebook) |
social_id |
VARCHAR(100) | Platform user ID |
access_token |
TEXT | OAuth access token |
data |
TEXT | JSON profile data |
ahm_sessions
Stores user session data.
CREATE TABLE {prefix}ahm_sessions (
id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
deviceID VARCHAR(64) NOT NULL,
name VARCHAR(100) NOT NULL,
value LONGTEXT,
expire INT(11) UNSIGNED NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY device_name (deviceID, name),
KEY expire (expire)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
| Column | Type | Description |
|---|---|---|
deviceID |
VARCHAR(64) | Device identifier |
name |
VARCHAR(100) | Session key |
value |
LONGTEXT | Serialized value |
expire |
INT | Expiration timestamp |
ahm_assets
Stores asset manager file data.
CREATE TABLE {prefix}ahm_assets (
id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
path VARCHAR(500) NOT NULL,
owner BIGINT(20) UNSIGNED NOT NULL,
file_type VARCHAR(50) DEFAULT NULL,
file_size BIGINT(20) UNSIGNED DEFAULT 0,
downloads INT(11) UNSIGNED DEFAULT 0,
metadata TEXT,
created DATETIME NOT NULL,
modified DATETIME NOT NULL,
PRIMARY KEY (id),
KEY owner (owner),
KEY path (path(191))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
ahm_user_download_counts
Tracks per-user download limits.
CREATE TABLE {prefix}ahm_user_download_counts (
id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
user BIGINT(20) UNSIGNED NOT NULL,
package_id BIGINT(20) UNSIGNED NOT NULL,
download_count INT(11) UNSIGNED DEFAULT 0,
last_download DATETIME DEFAULT NULL,
PRIMARY KEY (id),
UNIQUE KEY user_package (user, package_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
ahm_cron_jobs
Stores scheduled cron jobs.
CREATE TABLE {prefix}ahm_cron_jobs (
id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
code VARCHAR(100) NOT NULL,
type VARCHAR(50) NOT NULL,
data LONGTEXT,
status VARCHAR(20) DEFAULT 'pending',
execute_at INT(11) UNSIGNED NOT NULL,
executed_at INT(11) UNSIGNED DEFAULT NULL,
created_at INT(11) UNSIGNED NOT NULL,
repeat_count INT(11) DEFAULT 0,
interval_seconds INT(11) DEFAULT 0,
queue VARCHAR(50) DEFAULT 'default',
priority TINYINT(3) DEFAULT 10,
PRIMARY KEY (id),
UNIQUE KEY code (code),
KEY status_execute (status, execute_at),
KEY queue (queue)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
Premium Packages Tables
ahm_orders
Stores order data.
CREATE TABLE {prefix}ahm_orders (
id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
order_id VARCHAR(50) NOT NULL,
title VARCHAR(255) DEFAULT NULL,
uid BIGINT(20) UNSIGNED DEFAULT 0,
total DECIMAL(12,2) DEFAULT 0.00,
subtotal DECIMAL(12,2) DEFAULT 0.00,
tax DECIMAL(12,2) DEFAULT 0.00,
discount DECIMAL(12,2) DEFAULT 0.00,
currency VARCHAR(10) DEFAULT 'USD',
order_status VARCHAR(20) DEFAULT 'Pending',
payment_status VARCHAR(20) DEFAULT 'Pending',
payment_method VARCHAR(50) DEFAULT NULL,
transaction_id VARCHAR(100) DEFAULT NULL,
billing_info TEXT,
order_notes TEXT,
coupon VARCHAR(50) DEFAULT NULL,
date INT(11) UNSIGNED NOT NULL,
expire INT(11) UNSIGNED DEFAULT NULL,
ip VARCHAR(45) DEFAULT NULL,
extra TEXT,
PRIMARY KEY (id),
UNIQUE KEY order_id (order_id),
KEY uid (uid),
KEY payment_status (payment_status),
KEY date (date)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
| Column | Type | Description |
|---|---|---|
order_id |
VARCHAR(50) | Unique order identifier |
uid |
BIGINT | Customer user ID |
total |
DECIMAL(12,2) | Order total |
subtotal |
DECIMAL(12,2) | Pre-tax/discount total |
tax |
DECIMAL(12,2) | Tax amount |
discount |
DECIMAL(12,2) | Discount amount |
currency |
VARCHAR(10) | Currency code |
order_status |
VARCHAR(20) | Order status |
payment_status |
VARCHAR(20) | Payment status |
billing_info |
TEXT | JSON billing address |
date |
INT | Order timestamp |
expire |
INT | Access expiration |
ahm_order_items
Stores order line items.
CREATE TABLE {prefix}ahm_order_items (
id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
oid VARCHAR(50) NOT NULL,
pid BIGINT(20) UNSIGNED NOT NULL,
price DECIMAL(12,2) DEFAULT 0.00,
quantity INT(11) DEFAULT 1,
variations TEXT,
license VARCHAR(100) DEFAULT NULL,
license_key VARCHAR(255) DEFAULT NULL,
download_count INT(11) DEFAULT 0,
extra TEXT,
PRIMARY KEY (id),
KEY oid (oid),
KEY pid (pid)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
| Column | Type | Description |
|---|---|---|
oid |
VARCHAR(50) | Order ID reference |
pid |
BIGINT | Product/package ID |
price |
DECIMAL(12,2) | Item price |
quantity |
INT | Quantity ordered |
variations |
TEXT | JSON variation data |
license |
VARCHAR(100) | License tier name |
license_key |
VARCHAR(255) | Generated license key |
ahm_coupons
Stores coupon/discount codes.
CREATE TABLE {prefix}ahm_coupons (
id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
code VARCHAR(50) NOT NULL,
description VARCHAR(255) DEFAULT NULL,
discount_type VARCHAR(20) DEFAULT 'percent',
discount DECIMAL(12,2) DEFAULT 0.00,
min_order DECIMAL(12,2) DEFAULT 0.00,
max_discount DECIMAL(12,2) DEFAULT NULL,
usage_limit INT(11) DEFAULT 0,
usage_count INT(11) DEFAULT 0,
user_limit INT(11) DEFAULT 0,
products TEXT,
categories TEXT,
exclude_products TEXT,
start_date DATETIME DEFAULT NULL,
end_date DATETIME DEFAULT NULL,
status VARCHAR(20) DEFAULT 'active',
created DATETIME NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY code (code),
KEY status (status)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
| Column | Type | Description |
|---|---|---|
code |
VARCHAR(50) | Coupon code |
discount_type |
VARCHAR(20) | percent, fixed, fixed_cart |
discount |
DECIMAL(12,2) | Discount value |
min_order |
DECIMAL(12,2) | Minimum order amount |
max_discount |
DECIMAL(12,2) | Maximum discount cap |
usage_limit |
INT | Total usage limit (0=unlimited) |
user_limit |
INT | Per-user limit |
products |
TEXT | JSON product IDs |
categories |
TEXT | JSON category IDs |
ahm_licenses
Stores license key data.
CREATE TABLE {prefix}ahm_licenses (
id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
license_key VARCHAR(255) NOT NULL,
pid BIGINT(20) UNSIGNED NOT NULL,
oid VARCHAR(50) DEFAULT NULL,
uid BIGINT(20) UNSIGNED DEFAULT 0,
status VARCHAR(20) DEFAULT 'active',
activation_limit INT(11) DEFAULT 1,
activation_count INT(11) DEFAULT 0,
domains TEXT,
created DATETIME NOT NULL,
expires DATETIME DEFAULT NULL,
meta TEXT,
PRIMARY KEY (id),
UNIQUE KEY license_key (license_key),
KEY pid (pid),
KEY uid (uid),
KEY status (status)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
ahm_license_activations
Stores license activation records.
CREATE TABLE {prefix}ahm_license_activations (
id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
license_id BIGINT(20) UNSIGNED NOT NULL,
domain VARCHAR(255) NOT NULL,
ip VARCHAR(45) DEFAULT NULL,
activated_at DATETIME NOT NULL,
deactivated_at DATETIME DEFAULT NULL,
status VARCHAR(20) DEFAULT 'active',
PRIMARY KEY (id),
KEY license_id (license_id),
KEY domain (domain(191))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
ahm_withdraws
Stores seller payout requests.
CREATE TABLE {prefix}ahm_withdraws (
id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
user_id BIGINT(20) UNSIGNED NOT NULL,
amount DECIMAL(12,2) NOT NULL,
fee DECIMAL(12,2) DEFAULT 0.00,
net_amount DECIMAL(12,2) NOT NULL,
currency VARCHAR(10) DEFAULT 'USD',
payment_method VARCHAR(50) NOT NULL,
payment_details TEXT,
status VARCHAR(20) DEFAULT 'pending',
transaction_id VARCHAR(100) DEFAULT NULL,
notes TEXT,
requested_at DATETIME NOT NULL,
processed_at DATETIME DEFAULT NULL,
PRIMARY KEY (id),
KEY user_id (user_id),
KEY status (status)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
S3 Integration Table
ahm_amazons3_sync
Stores S3 sync status.
CREATE TABLE {prefix}ahm_amazons3_sync (
id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
PID BIGINT(20) UNSIGNED NOT NULL,
status VARCHAR(20) DEFAULT 'pending',
time INT(11) UNSIGNED NOT NULL,
message TEXT,
PRIMARY KEY (id),
UNIQUE KEY PID (PID)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
WordPress Core Tables Used
wp_posts
Packages stored as custom post type wpdmpro.
-- Key fields used post_type = 'wpdmpro' post_status = 'publish' | 'draft' | 'pending' post_author = user_id
wp_postmeta
All package metadata uses __wpdm_ prefix.
-- Common meta keys __wpdm_version -- Package version __wpdm_files -- Attached files (serialized array) __wpdm_download_count -- Download counter __wpdm_view_count -- View counter __wpdm_access -- Allowed roles (serialized array) __wpdm_password_lock -- Password lock enabled (0/1) __wpdm_password -- Lock password(s) __wpdm_email_lock -- Email lock enabled (0/1) __wpdm_template -- Link template name __wpdm_page_template -- Page template name
wp_terms / wp_term_taxonomy
Categories use taxonomy wpdmcategory.
Tags use taxonomy wpdmtag (constant WPDM_TAG).
Query Examples
Get Download Statistics
global $wpdb;
// Downloads per package this month
$stats = $wpdb->get_results($wpdb->prepare("
SELECT pid, COUNT(*) as downloads
FROM {$wpdb->prefix}ahm_download_stats
WHERE year = %d AND month = %d
GROUP BY pid
ORDER BY downloads DESC
LIMIT 10
", date('Y'), date('m')));
// Daily downloads for a package
$daily = $wpdb->get_results($wpdb->prepare("
SELECT day, COUNT(*) as count
FROM {$wpdb->prefix}ahm_download_stats
WHERE pid = %d AND year = %d AND month = %d
GROUP BY day
ORDER BY day
", $package_id, date('Y'), date('m')));
Get Email Subscribers
// Subscribers for a package
$subscribers = $wpdb->get_results($wpdb->prepare("
SELECT email, date, custom_data
FROM {$wpdb->prefix}ahm_emails
WHERE pid = %d
ORDER BY date DESC
", $package_id));
// Export all subscribers
$all = $wpdb->get_results("
SELECT DISTINCT email, MIN(date) as first_sub
FROM {$wpdb->prefix}ahm_emails
GROUP BY email
ORDER BY first_sub DESC
");
Get Order Data
// Recent orders
$orders = $wpdb->get_results($wpdb->prepare("
SELECT o.*, GROUP_CONCAT(oi.pid) as products
FROM {$wpdb->prefix}ahm_orders o
LEFT JOIN {$wpdb->prefix}ahm_order_items oi ON oi.oid = o.order_id
WHERE o.payment_status = 'Completed'
AND o.date >= %d
GROUP BY o.id
ORDER BY o.date DESC
LIMIT 50
", strtotime('-30 days')));
// Order with items
$order = $wpdb->get_row($wpdb->prepare("
SELECT * FROM {$wpdb->prefix}ahm_orders
WHERE order_id = %s
", $order_id));
$items = $wpdb->get_results($wpdb->prepare("
SELECT * FROM {$wpdb->prefix}ahm_order_items
WHERE oid = %s
", $order_id));
License Validation
$license = $wpdb->get_row($wpdb->prepare("
SELECT l.*, COUNT(a.id) as current_activations
FROM {$wpdb->prefix}ahm_licenses l
LEFT JOIN {$wpdb->prefix}ahm_license_activations a
ON a.license_id = l.id AND a.status = 'active'
WHERE l.license_key = %s
GROUP BY l.id
", $license_key));
Database Maintenance
Cleanup Expired Sessions
$wpdb->query($wpdb->prepare("
DELETE FROM {$wpdb->prefix}ahm_sessions
WHERE expire < %d
", time()));
Archive Old Statistics
// Move stats older than 1 year to archive table
$wpdb->query($wpdb->prepare("
INSERT INTO {$wpdb->prefix}ahm_download_stats_archive
SELECT * FROM {$wpdb->prefix}ahm_download_stats
WHERE timestamp query($wpdb->prepare("
DELETE FROM {$wpdb->prefix}ahm_download_stats
WHERE timestamp < %d
", strtotime('-1 year')));
Related Documentation
Last updated: January 2026
Applies to: WordPress Download Manager 7.x