Created
September 12, 2018 17:14
-
-
Save Brandonsmith23/ac1fa5f620ddbe4c216d703328c7fb49 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
/* | |
Plugin Name: My Custom Login | |
Version: 0.1-alpha | |
Description: Restrics page login | |
Author: Your Name | |
Author URI: Your URL | |
Plugin URI: Your URL | |
Text Domain: Your Text Domain | |
Domain Path: /languages | |
*/ | |
function user_filter_page_request() { | |
global $post; | |
if( !is_user_logged_in() && user_is_logged_in_page($post) ) { | |
wp_redirect( wp_login_url( get_permalink( $post->ID ) , true) ); | |
} | |
} | |
function user_is_logged_in_page($post) { | |
$post; | |
if( $post->ID == 223 ) //Add any page that does not need a login here, leave blank if that is never the case | |
return false; | |
else | |
return true; | |
} | |
add_action( 'template_redirect', 'user_filter_page_request' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment