I've tried multiple ways and edits to my functions.php file, however, I can't figure out or find a way which has worked for me.
A logged in user should be redirected from /zum-shop/ to /shop/ and a not logged in user should be redirected from /zum-shop/ to /mein-konto/
What must be changed in the code?
add_action('init','redirect_to_shop');
function redirect_to_shop() {
if ( is_user_logged_in() && ( strpos($_SERVER['REQUEST_URI'], '/zum-shop/') !== false )) {
wp_redirect('/shop/');
exit;
} else {
if ( strpos($_SERVER['REQUEST_URI'], '/zum-shop/') !== false ) {
wp_redirect('/mein-konto/');
exit;
}
}
}
source https://stackoverflow.com/questions/69288663/wordpress-redirect-a-user-if-they-are-logged-in-not-logged-in-only-if-they-are
Comments
Post a Comment