This function takes a post ID (or page Id, or custom post type ID), and returns a boolean true / false depending on whether or not that content is protected.
[php]
function is_memberium_protected( $post_id ) {
$post_id = (int) $post_id;
$post_metas = get_post_meta( $post_id );
$protection_keys = array(
‘_is4wp_access_tags’,
‘_is4wp_anonymous_only’,
‘_is4wp_any_loggedin_user’,
‘_is4wp_any_membership’,
‘_is4wp_contact_ids’,
‘_is4wp_membership_levels’,
);
foreach( $post_metas as $key => $value ) {
if ( in_array( $key, $protection_keys ) ) {
$value = implode( ”, $value );
if ( ! empty( $value ) ) {
return true;
}
}
}
return false;
}
[/php]