Created
September 8, 2013 23:41
-
-
Save offroadkev/6489584 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @package Redirect to login if not logged in | |
* @version 1.3 | |
*/ | |
/* | |
Plugin Name: Redirect to login if not logged in | |
Plugin URI: http://wordpress.org/plugins/redirect-to-login-if-not-logged-in/ | |
Description: Redirect to wp-login.php if user is not logged in. | |
Author: Daan Kortenbach | |
Version: 1.3 | |
Author URI: http://daan.kortenba.ch/ | |
*/ | |
add_action( 'wp', 'dmk_not_loggedin_redirect' ); | |
/** | |
* Redirect to wp-login.php if user is not logged in. | |
* | |
* @author Daan Kortenbach | |
* | |
* @global string $pagenow | |
* @return void redirect | |
*/ | |
function dmk_not_loggedin_redirect() { | |
global $pagenow; | |
if ( ! is_user_logged_in() && $pagenow != 'wp-login.php' ) | |
wp_redirect( wp_login_url(), 302 ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment