Created
December 11, 2023 13:48
-
-
Save plugin-republic/b3afda784c976115dfc3cc4d61cf2c0b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Restrict access to pages by log-in status | |
*/ | |
function prefix_is_post_restricted( $is_restricted, $restricted_content ) { | |
// Edit the page IDs below | |
$restricted_page_ids = array( 2, 10 ); | |
if( is_page() ) { | |
$page_id = get_the_ID(); | |
if( in_array( $page_id, $restricted_page_ids ) ) { | |
if( ! is_user_logged_in() ) { | |
return true; | |
} | |
} | |
} | |
return $is_restricted; | |
} | |
add_filter( 'wcmo_is_content_restricted', 'prefix_is_post_restricted', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment