How to Restrict Ultimate Member Login Page for logged in users using Hooks?

Photo of author
Written By geekerhub

Lorem ipsum dolor sit amet consectetur pulvinar ligula augue quis venenatis. 

In Ultimate Member, If user is logged in then also logged in user can access login page.

To make this behaviour user friendly, we can allow redirect to the profile page if user is logged in when trying to access login page.

function um_restrict_login_page_logged_in() {
    if ( um_is_core_page('login') && is_user_logged_in() ) {
    	 *logged in user will redirect to user profile page. You can set any page for redirection
        wp_redirect( um_get_core_page( 'user' ) );
add_action( 'template_redirect', 'um_restrict_login_page_logged_in' );

Leave a Comment