Skip to content

Instantly share code, notes, and snippets.

@plugin-republic
Created December 12, 2023 13:38
Show Gist options
  • Save plugin-republic/56aab86857a7c1fc41f6360c87ecf304 to your computer and use it in GitHub Desktop.
Save plugin-republic/56aab86857a7c1fc41f6360c87ecf304 to your computer and use it in GitHub Desktop.
<?php
/**
* Filter restriction by page ID for user roles
*/
function prefix_is_restricted_redirect( $is_restricted ) {
$restricted_page_ids = array( 2, 10 );
if( is_page() ) {
$page_id = get_the_ID();
if( in_array( $page_id, $restricted_page_ids ) ) {
$is_permitted_user_role = wcmo_is_permitted_user_role();
if( ! wcmo_is_permitted_user_role() ) {
$is_restricted = true;
}
}
}
return $is_restricted;
}
add_filter( 'wcmo_is_restricted_redirect', 'prefix_is_restricted_redirect', 10 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment