is_memberium_protected()

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]

  • Was this Helpful?
  • YesNo
9 ways to add more value to your membership site

Table of Contents

Keep Reading

Infusionsoft Username Field

This dropdown selects which fields in your Infusionsoft contact record is used to match the login name to. Currently we only support email fields, and we encourage you to use “Email” as your username. This provides the most reliability and maximum compatibility.

Read More »

How to Create a Membership Level

Membership levels can be created easily using the Memberium Dashboard. During initial setup we offer to do this free for you, but there’s no reason you can’t make or change your own membership levels yourself. This guide will walk you through the steps.

Read More »

Want to get some fresh ideas on how you can improve your membership site or course?

Download our free ebook!

Book a Call

Welcome to Memberium!

We are very excited for you to be part of our family. 

We would love to answer any questions that you have!

Please choose the best time for you to get in a call with us. 

For Technical Support, you can contact us at https://keap.memberium.com/support/ or Email us at support@memberium.com.