You can use Private Magic Links extension to embed your protected WordPress files, pages and posts into your content then dynamically automate a new expiring link within a period of time that you’ve set beforehand.
Requirements:
- Prevent Direct Access Gold version 3.0.25.4 or greater
- PDA Private Magic Links version 1.0.0 or greater
The following are our step-by-step guides on how to apply Private Magic Links (PML) to protected files and content.
Use PML with Protected Files by PDA Gold
Step 1: Once you’ve installed Private Magic Links extension, go to Prevent Direct Access Gold Settings
page and click on “Magic Links” tab.
Under this tab, you can:
- Update the expiration time of generated magic links to what you desire.
- Select user roles who can access generated magic links.
- Search & replace embedded file URLs with magic links on specific posts or pages only.
- Our extension will automatically search & replace file URLs on all pages and posts by default.
Step 2: Protect and embed your files into content as normal.
Use PML with Protected Content by PPP Gold
Step 1: Navigate to Content Protection > Magic Links under your admin dashboard.
Here you can set a default expiration time for auto-generated magic links.
Step 2: Protect your content and insert the link of your protected pages or posts into your content as normal
That’s all you have to do. Now our Private Magic Links extension will expire and automate your protected pages’ private link according to the expire time you set on Step 1.
Available Custom Snippets
Disable Search & Replace Function
Upon activating the Private Magic Links extension, our Search & Replace function is turned on by default. It means that your protected file/page URLs in the content will be replaced by Private Magic Links automatically.
Since Private Magic Links version 1.1.0, you can disable this function by adding the following code snippet to your (child) theme functions.php or Code Snippets plugin.
add_filter( 'pda_ml_enable_search_and_replace', '__return_false' );
Search & Replace Custom Post Types
By default, our Search & Replace function is applicable to Pages and Posts only.
In case of Custom Post Types, simply add the following code snippet to your (child) theme functions.php file.
add_filter( 'pda_ml_search_and_replace_cpts', function ( $allowed, $post_id ) {
$post_type = get_post_type( $post_id );
$post_types = [ 'your-custom-post-types-slug' ];
if ( in_array( $post_type, $post_types ) ) {
return true;
}
return $allowed;
}, 15, 2 );
How to apply our Search & Replace function on specific content only (Optional)
add_filter( 'pda_ml_search_and_replace_cpts', function ( $allowed, $post_id ) {
$post_ids = [ your-post-ID ];
if ( in_array( $post_id, $post_ids ) ) {
return true;
}
return $allowed;
}, 10, 2 );
The filter is available from version 1.1.0.