CPT protection

If you want to protect a custom post type (CPT) in WordPress to be only available to logged-in users or make sure they login.

function some_func( $query ){
if ( is_post_type_archive('nieuwsbrief') && !is_user_logged_in() ) {
// Do stuff
wp_redirect('/wp-login.php'); }

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.