Simple redirect unauthenticaed WordPress users

Put this at the top of your template you want to restrict:

<?php
/**
 * If user's not logged in, send to login page.
 */
if (!current_user_can('read')) {
    header('Location: ' . wp_login_url(get_permalink()));
    exit;
}

Posted

in

,

by

Tags:

Comments

Leave a Reply

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