Skip to main content
PRO Only
Pro Feature

This page documents Pro edition shortcodes. Upgrade to Pro to access these shortcodes.

Pro: Shortcodes Reference

Complete reference for all Pro edition shortcodes. This page documents every shortcode, its attributes, usage examples, and output.

Available Shortcodes

Pro edition includes all FREE shortcodes plus:

  • [download_limits] - Display user's download limits
  • [somdn_user_free_downloads_history] - Display download history

See Shortcodes Reference (FREE) for FREE edition shortcodes.

[download_limits]

Display current user's download limits and usage.

Basic Usage

[download_limits]

Output

Shows:

  • Current downloads this period
  • Total allowance
  • Remaining downloads
  • Reset date/time
  • Product allowance (if applicable)

Example Output

You have downloaded 3 files today.
Your limit is 5 downloads per day.
You have 2 downloads remaining.
Your limit resets in 8 hours.

Attributes

This shortcode has no attributes.

Requirements

  • Download limits must be enabled
  • Download tracking must be enabled
  • User must have applicable limits

Display Conditions

For Logged-In Users:

  • Shows user-specific limits
  • Displays accurate count
  • Shows remaining downloads

For Guests:

  • Shows IP-based limits (if configured)
  • Less accurate tracking
  • May show generic message

No Limits:

  • Shows "No download limits" message
  • Or custom message via filter

Styling

Default CSS classes:

.somdn-download-limits {
/* Container */
}

.somdn-limits-current {
/* Current downloads count */
}

.somdn-limits-total {
/* Total allowance */
}

.somdn-limits-remaining {
/* Remaining downloads */
}

.somdn-limits-reset {
/* Reset time */
}

Customization

Custom Template:

  1. Copy template from plugin:

    /plugins/free-downloads-woocommerce-pro/templates/download-limits.php
  2. Paste to theme:

    /themes/your-theme/somdn-templates/download-limits.php
  3. Customize as needed

Custom Text:

add_filter('somdn_limits_display_text', function($text, $current, $limit, $remaining) {
return "You've used {$current} of {$limit} downloads. {$remaining} left!";
}, 10, 4);

Hide When No Limits:

add_filter('somdn_show_limits_when_none', '__return_false');

Use Cases

Account Dashboard:

<h2>Your Download Limits</h2>
[download_limits]

Sidebar Widget:

<div class="widget">
<h3>Downloads</h3>
[download_limits]
</div>

Before Download Button:

[download_limits]
[download_now id="123"]

Troubleshooting

Shortcode Not Working:

  1. ✅ Verify limits are enabled
  2. ✅ Check tracking is enabled
  3. ✅ Confirm user has limits
  4. ✅ Test with different user
  5. ✅ Check for shortcode conflicts

Wrong Count Displayed:

  1. ✅ Clear all caches
  2. ✅ Verify limit frequency
  3. ✅ Check date/time settings
  4. ✅ Review custom filters
  5. ✅ Test with fresh download

[somdn_user_free_downloads_history]

Display logged-in user's free download history.

Basic Usage

[somdn_user_free_downloads_history]

Output

Shows table with:

  • Product name
  • Download date
  • Number of files
  • Re-download button

Attributes

limit

Limit number of downloads displayed.

Type: Integer
Default: All downloads
Example:

[somdn_user_free_downloads_history limit="10"]

Shows only 10 most recent downloads.

days

Show only downloads from last X days.

Type: Integer
Default: All time
Example:

[somdn_user_free_downloads_history days="30"]

Shows only downloads from last 30 days.

show_redownload

Show or hide re-download buttons.

Type: Boolean (true/false)
Default: true
Example:

[somdn_user_free_downloads_history show_redownload="false"]

Hides re-download buttons.

show_limits

Show or hide download limits section.

Type: Boolean (true/false)
Default: true
Example:

[somdn_user_free_downloads_history show_limits="false"]

Hides limits section above history.

Combined Attributes

[somdn_user_free_downloads_history limit="5" days="7" show_redownload="true" show_limits="false"]

Shows 5 most recent downloads from last 7 days with re-download buttons but no limits section.

Requirements

  • Download tracking must be enabled
  • User must be logged in
  • User must have downloads

Display Conditions

For Logged-In Users:

  • Shows their download history
  • Displays re-download buttons
  • Shows download limits (if enabled)

For Guests:

  • Shows login prompt
  • Or custom message
  • No history displayed

Styling

Default CSS classes:

.somdn-account-history-table {
/* History table */
}

.somdn-account-history-table th {
/* Table headers */
}

.somdn-account-history-table td {
/* Table cells */
}

.somdn-redownload-button {
/* Re-download button */
}

.somdn-history-pagination {
/* Pagination */
}

Customization

Custom Template:

  1. Copy template from plugin:

    /plugins/free-downloads-woocommerce-pro/templates/account/free-download-history.php
  2. Paste to theme:

    /themes/your-theme/somdn-templates/account/free-download-history.php
  3. Customize as needed

Custom Login Message:

add_filter('somdn_history_login_message', function($message) {
return 'Please <a href="/my-account/">log in</a> to view your downloads.';
});

Custom Columns:

add_filter('somdn_history_columns', function($columns) {
$columns['custom'] = 'Custom Column';
return $columns;
});

add_filter('somdn_history_column_custom', function($value, $download_id) {
return 'Custom value';
}, 10, 2);

Pagination:

add_filter('somdn_history_per_page', function($per_page) {
return 20; // Show 20 per page
});

Use Cases

Custom Account Page:

<h1>My Downloads</h1>
<p>View and re-download your free products.</p>
[somdn_user_free_downloads_history]

Member Dashboard:

<div class="member-downloads">
<h2>Recent Downloads</h2>
[somdn_user_free_downloads_history limit="5" show_limits="false"]
</div>

Download Portal:

<div class="download-portal">
[download_limits]
<hr>
<h3>Your Download History</h3>
[somdn_user_free_downloads_history days="90"]
</div>

Troubleshooting

Shortcode Not Working:

  1. ✅ Verify tracking is enabled
  2. ✅ Check user is logged in
  3. ✅ Confirm user has downloads
  4. ✅ Test with different user
  5. ✅ Check for shortcode conflicts

History Not Showing:

  1. ✅ Verify user has downloads
  2. ✅ Check date range (days attribute)
  3. ✅ Clear all caches
  4. ✅ Review custom filters
  5. ✅ Test without attributes

Re-Download Not Working:

  1. ✅ Check files still exist
  2. ✅ Verify user permissions
  3. ✅ Check download limits
  4. ✅ Look for PHP errors
  5. ✅ Test with different download

Combining Shortcodes

Download Portal

Create complete download portal:

<div class="download-portal">
<h1>Your Downloads</h1>

<div class="limits-section">
<h2>Download Limits</h2>
[download_limits]
</div>

<div class="history-section">
<h2>Download History</h2>
[somdn_user_free_downloads_history limit="10"]
</div>

<div class="browse-section">
<h2>Browse Free Products</h2>
[products limit="8" columns="4" category="free-downloads"]
</div>
</div>

Member Dashboard Widget

<div class="widget member-downloads">
<h3>Your Downloads</h3>
[download_limits]
<hr>
<h4>Recent Downloads</h4>
[somdn_user_free_downloads_history limit="3" show_limits="false"]
<a href="/downloads/">View All Downloads →</a>
</div>

Product Page Enhancement

<div class="product-downloads">
<h2>Free Download</h2>
[download_now id="123"]

<div class="download-info">
<p>Your remaining downloads:</p>
[download_limits]
</div>
</div>

Developer Reference

Shortcode Registration

Pro shortcodes are registered in:

/pro/includes/somdn-pro-shortcodes.php

Shortcode Functions

somdn_download_limits_shortcode() Handles [download_limits] shortcode.

somdn_user_history_shortcode() Handles [somdn_user_free_downloads_history] shortcode.

Filters

somdn_limits_shortcode_output Modify limits shortcode output.

add_filter('somdn_limits_shortcode_output', function($output, $user_id) {
// Customize output
return $output;
}, 10, 2);

somdn_history_shortcode_output Modify history shortcode output.

add_filter('somdn_history_shortcode_output', function($output, $user_id, $atts) {
// Customize output
return $output;
}, 10, 3);

somdn_history_shortcode_atts Modify shortcode attributes.

add_filter('somdn_history_shortcode_atts', function($atts) {
// Set defaults
$atts['limit'] = 20;
return $atts;
});

Actions

somdn_before_limits_shortcode Before limits shortcode output.

add_action('somdn_before_limits_shortcode', function($user_id) {
echo '<div class="custom-wrapper">';
});

somdn_after_limits_shortcode After limits shortcode output.

add_action('somdn_after_limits_shortcode', function($user_id) {
echo '</div>';
});

somdn_before_history_shortcode Before history shortcode output.

add_action('somdn_before_history_shortcode', function($user_id, $atts) {
echo '<div class="history-wrapper">';
}, 10, 2);

somdn_after_history_shortcode After history shortcode output.

add_action('somdn_after_history_shortcode', function($user_id, $atts) {
echo '</div>';
}, 10, 2);

Best Practices

Shortcode Usage

  • Test first: Test shortcodes before going live
  • Use attributes: Customize with attributes
  • Style appropriately: Add custom CSS
  • Mobile friendly: Ensure mobile compatibility

Performance

  • Limit results: Use limit attribute for large histories
  • Cache output: Cache shortcode output when possible
  • Optimize queries: Use efficient database queries
  • Lazy load: Load history on demand

User Experience

  • Clear labels: Use descriptive headings
  • Helpful messages: Provide context
  • Easy navigation: Add pagination
  • Responsive design: Mobile-first approach

Security

  • Verify users: Check user permissions
  • Sanitize output: Escape all output
  • Validate input: Validate shortcode attributes
  • Nonce protection: Use nonces for actions