Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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