Skip to content

Instantly share code, notes, and snippets.

@marushu
Last active April 19, 2016 10:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marushu/69b017f446f7df2c6a54f00e8f334ca7 to your computer and use it in GitHub Desktop.
Save marushu/69b017f446f7df2c6a54f00e8f334ca7 to your computer and use it in GitHub Desktop.
<?php
add_filter( 'wp', 'only_login_user', 0 );
function only_login_user( $content ) {
global $post;
$post_type = 'post_type';
$taxonomy = $taxonomy;
if( ! is_admin() && ( get_post_type() === $post_type || is_tax( $taxonomy ) )
&& ! is_user_logged_in() ) {
wp_redirect( get_home_url() );
exit;
}
return $content;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment