Check if Post/Page is Protected Programmatically

I’m looking for a way inside of a loop to tell if a given post or page is protected. Sorry if this was obvious some where in the documentation but i was unable to find it.

Something like the example below is what i’m looking for.

if(is_protected($post->ID)) {

//add some kind of class letting users know the content is protected before they click

}

  • Patrick Cohen
    • Technical Docs Wrangler

    Hi there @Brian

    Welcome to WPMU DEV, glad to have you aboard!

    The Membership2 Pro plugin is the first of our products to include full developer documentation where you’ll find everything you could ever hope for code-wise. :slight_smile:

    You’ll find a link to the Developer Docs under Membership2 > Help > Advanced Settings

    I hope this helps! And thanks for being a member :slight_smile: