Created
February 26, 2025 12:15
-
-
Save yuriinalivaiko/0fb1252856b698342d4804b33173c689 to your computer and use it in GitHub Desktop.
Ultimate Member customization. Redirect logged in users from the Login page.
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 | |
// Redirect logged in users from the Login page to the page specified in the role setting “Set Custom Redirect URL”. | |
add_action( 'template_redirect', function() { | |
if ( function_exists( 'um_is_core_page' ) && um_is_core_page( 'login' ) && is_user_logged_in() ) { | |
if ( um_user( 'login_redirect_url' ) ) { | |
$redirect_url = apply_filters( 'um_login_redirect_url', um_user( 'login_redirect_url' ), um_user( 'ID' ) ); | |
} else { | |
$redirect_url = home_url(); | |
} | |
exit( wp_safe_redirect( $redirect_url ) ); | |
} | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
User Role settings:

Alternative solution: you can use a page content restriction settings with the code snippet in the article How to Restrict & Redirect Login Page.