Home / Archive / MemberPress: Disable MemberPress Protection On Posts with Specific Tags
Duplicate Snippet

Embed Snippet on Your Site

MemberPress: Disable MemberPress Protection On Posts with Specific Tags

This code snippet disables content protection for posts that are tagged with a specific term (e.g., 'free').

The sample code below will remove the protection on posts with the tag free and make them publicly available.

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 "free" tag and if you want to add more than one tag just add (, 'tag')
  if (has_tag(array('free'), $post)) {
    $protect = false; // Disable protection for these posts
  }
  return $protect;
}

Comments

Add a Comment