Skip to content
Reallyusefulplugins.com Docs

CSS / Protected Content Filters

Updated 17 October 2026

The following filter and snippet change the content-protected options with additional styling and more branding to give you more control

<?php
function selective_custom_protected_content_output($output, $post_id, $purchase_link) {
    // Define an array of post IDs where the hook should apply
    $allowed_posts = array(362);
 
    // Get the post content
    $post_content = get_post_field('post_content', $post_id);
 
    // Check for the presence of the marker
    $marker = '<!--protected-->';
    if (strpos($post_content, $marker) !== false) {
        // Split content at the marker
        $preview_content = explode($marker, $post_content)[0];
    } else {
        // No marker, protect the entire content
        $preview_content = '';
    }
 
    // Check if the current post ID is in the allowed posts array
    if (in_array($post_id, $allowed_posts)) {
        // Generate the protected content output
        $protected_message = sprintf(
            '<div class="custom-protected-content-message" style="text-align: center; padding: 20px;">
                <p style="font-size: 24px; color: #007bff; font-weight: bold; margin-bottom: 20px;">
                    🔒 This content is protected.
                </p>
                <a href="%s" class="custom-purchase-link button"
                   style="background: #007bff; color: #fff; padding: 12px 24px; border-radius: 5px; text-decoration: none; font-size: 18px; display: inline-flex; align-items: center;">
                    <span class="dashicons dashicons-admin-network" style="margin-right: 8px;"></span> Unlock Access
                </a>
            </div>',
            esc_url($purchase_link)
        );
 
        // Return the preview content with the protected message
        return $preview_content . $protected_message;
    }
 
    // Return the original output if the post ID is not in the allowed array
    return $output;
}
add_filter('rup_sell_ind_posts_wsc_protected_content_output', 'selective_custom_protected_content_output', 10, 3);

The below snippet will protect all content and ignore the marker <!— protected –> and protect and style ALL content you could combine these two snippets for example to make one that ignores the marker on certain pages!

function custom_protected_content_output($output, $post_id, $purchase_link) {
    return sprintf(
        '<div class="custom-protected-content-message" style="text-align: center; padding: 20px;">
            <p style="font-size: 24px; color: #007bff; font-weight: bold; margin-bottom: 20px;">
                🔒 This content is protected.
            </p>
            <a href="%s" class="custom-purchase-link button"
               style="background: #007bff; color: #fff; padding: 12px 24px; border-radius: 5px; text-decoration: none; font-size: 18px; display: inline-flex; align-items: center;">
                <span class="dashicons dashicons-admin-network" style="margin-right: 8px;"></span> Unlock Access
            </a>
        </div>',
        esc_url($purchase_link)
    );
}
add_filter('rup_sell_ind_posts_wsc_protected_content_output', 'custom_protected_content_output', 10, 3);

Was this helpful?

Still stuck? Open a support ticket