S2member Remove Restrictions for Specific Posts

Sometimes you have a set of custom posts that are subscriber only. Sometimes you want a couple posts to be available publicly. Unfortunately there’s not a well documented way to do this, and the last thread on the topic received the response “there isn’t that yet.”

That was in 2012, we’re in the future and there is that now – but you have to dig. Well you don’t have to dig, the digging has been done, here’s the dirt:


add_action( 'ws_plugin__s2member_check_post_level_access_excluded', 'set_s2member_restriction' );

function set_s2member_restriction() {
  global $post;

  switch ($post->ID) {
    case 1: // Post IDs you want to allow public access to
    case 2:
      return true;
  }

  return false;
}

Add that in your functions.php file and you’re all set.