Apply the_content filter for specific post types only

I’m trying to modify a snippet of code I found here for a wordpress website:

Here is the code:

add_filter( 'the_content', 'restrict_mm_access' );

function restrict_mm_access($content) {

    return $content;

$moreLink = '<span id="more-' . get_the_ID() . '"></span>';

$contentData = explode( $moreLink, $content );

if ( count( $contentData ) > 1 ) {
    $return = $contentData[0];
    $return .= "[MM_Member_Decision isMember='false']";
    $return .= '<div id="access-restricted-box">
                    <h3>You have to be a member to access this content.</h3>
                    <h4>Already a Member?</h4>
                    <a href="/login/?redirect_to=' . get_the_permalink() . '" class="button">Log In for Access</a>
                    <h4>Not a Member Yet?</h4>
                    <a href="/join/" class="button">Register Now</a>
    $return .= "[/MM_Member_Decision]";
    $return .= "[MM_Member_Decision membershipId='2']";
    $return .= $contentData[1];
    $return .= "[/MM_Member_Decision]";

    return $return;
} else {
    return $content;

I’m using the Member Mouse membership plugin to protect custom posts; so they are only displayed for paid members. Our blog postings are publicly available.

The above snippet works perfect for protecting blog postings – which isn’t what I want. I want two custom post types protected (Tools, and Articles), and the blog postings to display to everyone.

I recognize that Custom post types are not posts – so there’s the problem. I just don’t know how to modify the snippet to work.

Any ideas?

Solutions Collecting From Web of "Apply the_content filter for specific post types only"