-
-
Save szbl/4287121 to your computer and use it in GitHub Desktop.
This file contains 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 | |
function utm_welcome_redirect() { | |
// redirect anyone that is not logged in to /welcome | |
if ( !is_user_logged_in() ) | |
{ | |
wp_redirect( site_url( '/welcome' ), 303 ); | |
die; | |
} | |
else | |
{ | |
// only redirect if user is NOT requesting an admin URL (requires password) | |
// and is not at the URL we want them to be at. | |
if ( !is_admin() && !empty( $_SERVER['REQUEST_URI'] ) && $_SERVER['REQUEST_URI'] != '/' ) | |
wp_redirect( get_bloginfo( 'wpurl' ), 303 ); | |
// example to use if you want to simply keep them away from /welcome if logged in | |
/* | |
$uri = explode( '/', trim( $_SERVER['REQUEST_URI'], '/' ) ); | |
if ( isset( $uri[0] ) && $uri[0] == 'welcome ') | |
wp_redirect( get_bloginfo( 'wpurl' ), 303 ); | |
*/ | |
die; | |
} | |
} | |
add_action( 'init', 'utm_welcome_redirect' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment