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

A Guide to Using Shortcodes

This article covers the various concepts around Memberium Shortcodes: Conditional Shortcodes, How to Nest Shortcodes, Troubleshooting Shortcodes, Local Variables, Capturing Your Output for Later, and Formatting Your Output.

Read More »

Field Copy HTTP POST

This function extends your Infusionsoft system with an easy way to enable you to copy the value from one field to another field on your contact record.  

Read More »

Password Reset Tag

This is the tag that is applied to users who use the WordPress password reset function This is experimental. This setting is optional. The default

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.