Hello @hannahestes
You can use the get_post_privacy_settings method to get the post restriction settings. This method tries to get restriction settings from the um_content_restriction post meta first, then tries to get restriction settings from related terms. return bool|array
$post_id = 233;
$restriction = UM()->access()->get_post_privacy_settings( $post_id );
You can use the is_restricted method to test if the post is restricted or not. return bool
$post_id = 233;
$restricted = UM()->access()->is_restricted( $post_id );
You can use the um_is_restricted_post hook to change the result of the is_restricted method. This hook does not work for administrators because administrators can access restricted posts.
function um_is_restricted_post_filter( $restricted, $post_id, $on_single_page ) {
if ( $post_id === 233 ) {
$restricted = true;
}
return $restricted;
}
add_filter( 'um_is_restricted_post', 'um_is_restricted_post_filter', 10, 3 );
You can get the term restriction settings from the um_content_restriction term meta.
$term_id = 45;
$restriction = get_term_meta( $term_id, 'um_content_restriction', true );
You can use the is_restricted_term method to test if the term is restricted or not. return bool
$term_id = 45;
$restricted = UM()->access()->is_restricted_term( $term_id );
You can use the um_is_restricted_term hook to change the result of the is_restricted_term method. This hook does not work for administrators because administrators can access restricted terms.
function um_is_restricted_term_filter( $restricted, $term_id, $on_term_page ) {
if ( $term_id === 45 ) {
$restricted = true;
}
return $restricted;
}
add_filter( 'um_is_restricted_term', 'um_is_restricted_term_filter', 10, 3 );
Regards