Skip to content

Instantly share code, notes, and snippets.

@lynt-smitka
Last active November 4, 2020 21:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lynt-smitka/935a6b28fcdbc7555277aa7075b6733f to your computer and use it in GitHub Desktop.
Save lynt-smitka/935a6b28fcdbc7555277aa7075b6733f to your computer and use it in GitHub Desktop.
function lynt_redirect_to_login(){
if ( is_page(123) && !is_user_logged_in() ) auth_redirect();
}
add_action('get_header', 'lynt_redirect_to_login');
// in_category('private-category') - test if the current post exists in particular category
// wp_get_post_parent_id(get_the_ID()) === 2 - test if the current page is the child of the page defined by its ID
// get_current_user_id() === 3 - test if the current user is the specific user defined by his ID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment