Home / Archive / MemberPress: Disable MemberPress Protection On Multiple Specified Pages
Duplicate Snippet

Embed Snippet on Your Site

MemberPress: Disable MemberPress Protection On Multiple Specified Pages

This snippet allows disabling the MemberPress protection (unprotect) on multiple specified pages. The code snippets overrides the MemberPress content protection rules, based on the page slugs and IDs.

The sample code will remove the protection on pages with specified slugs (slug1 and slug2), and also the page with spcofoed IDs (123 and 456).

Code Preview
php
<?php
add_filter('mepr-pre-run-rule-content', 'mepr_override_content_protection', 11, 3);
function mepr_override_content_protection($protect, $post, $uri) {
    // Unprotect posts with the specified page slug or ID
    if ( is_page( array( 'slug1', 'slug2', 123, 456 ) ) ) {
        $protect = false; // Disable protection for the specified pages
    }
    return $protect;
}

Comments

Add a Comment