If user enters the url www.abc.com in the browser and he is not logged in, then we want to redirect him to www.abc.com/de. How can I do this within WordPress?
1 Answer
function redirect_user() {
if ( $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] == 'www.abc.com/' ) {
if ( ! is_user_logged_in() ) {
wp_redirect( 'http://www.abc.com/de/' );
exit;
}
}
}
add_action( 'init', 'redirect_user' );
Do you mean something like this?
-
But this need to be added into a function, and this function should be added before an action right? something like this: add_action('some_action', 'this_function'). What should be that 'some_action'?– JoshuaSep 24, 2012 at 19:53
-