Restrict Content Pro
rcp_get_post_restrictions()
Coming soon: Restrict Content Pro is becoming Kadence Memberships. You may see both names used while we update the product, documentation, and customer experience.
Note: This content is provided as a resource within our developer documentation. Because custom code requires highly specific implementation, we encourage you to work with a qualified developer if you need guidance. You can find our recommended consultants here: https://codeable.io/developers/restrict-content-pro
Returns an array describing membership and access requirements for a post.
If the post type has global RCP restrictions configured, those post-type rules are returned. Otherwise, values come from the individual post’s restriction metabox. Taxonomy/term restrictions are not included; use rcp_get_term_restrictions() per term. This does not tell you whether the current user can view the post; use rcp_user_can_access() for that.
Parameters
$post_id (int) – Post ID.
Return values
(array) – Keys (defaults shown when not set):
membership_levels (string|array) – Empty string by default. May beÂany,Âany-paid, or an array of membership level IDs.access_level (int) – Required access level. DefaultÂ0.user_level (array) – Required WordPress roles/capabilities. Default empty array.
Examples
$restrictions = rcp_get_post_restrictions( get_the_ID() );
if ( ! empty( $restrictions['membership_levels'] ) ) {
// Post requires specific membership level(s) or any/any-paid.
}
$restrictions = rcp_get_post_restrictions( 100 );
$level = isset( $restrictions['access_level'] ) ? (int) $restrictions['access_level'] : 0;