• Resolved Ratalinux

    (@ratalinux)


    I’m trying to accomplish that when a logged user hits the UM login page, instead of seeing his/her avatar and user info, he/she gets redirected someplace else (ie. the home page), just exactly as this user explains.

    I read the answer from the support team on that thread, which is activating the UM Restriction at page level, selecting “logged out users” on “Who can access this content” and then selecting “Redirect user” on “What happens when users without access tries to view the content?” and finally setting a custom URL on “Where should users be redirected to”. Unfortunately, the suggested settings didn’t work.

    I continued looking for a solution until I found this other thread, in which many other users report an issue when trying to restrict access to already logged users. Support staff advised to check about this documentation, which I already did, also without any luck. Regardless of a final advice on this last thread about setting global access to “restricted to logged users” (which I also tried, but doing so would change the whole thing completely), it seems like the issue remains unsolved.

    Is there anything else I can do to accomplish what I need?

    Thanks in advice!

    • This topic was modified 3 years, 11 months ago by Ratalinux.
    • This topic was modified 3 years, 11 months ago by Ratalinux.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @ratalinux

    Have you tried changing the login/register redirection in the User Role settings?

    Please go to WP Admin > Ultimate Member > User Roles > Edit a Role > see “Login Options” > see “Actions to be taken after login”. For Register, see “Register Options” > see “Actions to be taken after registration”.

    Regards,

    Thread Starter Ratalinux

    (@ratalinux)

    Hi @champsupertramp and thanks for the reply!

    The thing is that the suggestion you make is meant to when a user actually registers or logs in. This is working fine and I have that setup already.

    I’m referring to the case of a user that is already logged in to the site and, due to any circumstance (let’s say stepping in to the site from a bookmark pointed to the site’s login page), the user hits the login page again. In that scenario, UM will display his avatar, the user name and links to access his account and to log out.

    What I’m trying to accomplish is that, instead of seeing that, the users gets redirected to the site’s home page.

    Regards

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @ratalinux

    Please try these code snippets to redirect users to the homepage when accessing the Login page while logged in.

    add_action("template_redirect",function(){
    
        if( function_exists("um_is_core_page") && um_is_core_page("login") && is_user_logged_in() ){
            wp_redirect( "/" );
        }
    
    });

    You can add the above code to your theme’s functions.php file or use the Code Snippets plugin to run the code.

    Regards,

    • This reply was modified 3 years, 11 months ago by Champ Camba.
    Thread Starter Ratalinux

    (@ratalinux)

    Thanks @champsupertramp once again for the reply!

    I added the code, but nothing changed.

    If I understand your suggestion properly, that code hooks (through add_action() function) a template_redirect() function, which should be called afterwards when needed via a do_action() call.

    I can’t tell if that call is already part of the UM core or if I should add the call myself somewhere to be triggered when a user hits the login page.

    Am I wrong?

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @ratalinux

    Sorry for the late response.

    You can add the code in your theme’s function.php file or use the Code Snippets plugin to run the following code:

    add_action("template_redirect",function(){
    
        if( function_exists("um_is_core_page") && um_is_core_page("login") && is_user_logged_in() ){
            wp_redirect( "/" );
        }
    
    });

    Regards,

    Thread Starter Ratalinux

    (@ratalinux)

    Hi @champsupertramp!

    I made a rookie mistake… I added the code snippet, but I never activate it!

    Now I did and voila!

    Thanks! ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘UM Restriction Not working when logged’ is closed to new replies.