This topic has 9 replies, 3 voices, and was last updated 8 years by Radu.

  • Author
  • #168407
     Gavsta
    Participant

    Hi,

    Is there a way to change how the redirect works when i use the built in kleo login module? It redirects to the home page currently, but i would like to redirect the user back to the previous page once they log in.

    I saw that i can provide a custom URL for the redirection but the URL will change depending on which page the user is on.

    context: On my pages for my venues, i split the events into new members and existing members. I have added the kleo login module to the section for existing members so they can log in without having to navigate away from the page. We have about 30 venues, so 30 possible pages that they could need redirecting to depending on where they are from.

    Is this possible?

    Thanks,

    PhilB

    #168490
     Laura
    Moderator

    Hello, can you share access so i can check it out? 🙂

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #168515
     Gavsta
    Participant

    Hi,

    The site is on a development server at the moment. I can share the link to that and the page i am working on at the moment. There aren’t as many venues to work with there.

    how do i send details? do i need to make a private reply?

    As i mentioned in my other ticket, if i can get the redirect to go back to the page they were on then i wont need to hide the content (mentioned in the other ticket).

    Thanks,

    Phil

    #168579
     Laura
    Moderator

    Hello, yes please share as a private reply 🙂

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #168625
     Gavsta
    Participant

    Hi Laura,

    Not a problem. The site is located at http://lgtest.quadris.biz and the page i am working on is here: http://lgtest.quadris.biz/quadris-gc/

    Its my staging server and can run a bit slow sometimes.

    you can login with the following details

    username: laura_kleo
    password: VvtHRFq0gONBUn8pkNT64JSV

    I had some success with the login and redirection yesterday. I have the login box on that page, and now when you login it redirects you back to the correct tab.

    Issues at the moment:

    Admin’s are no longer taken to the administrators dashboard.
    Also, the URL that is output doesn’t look very clean with pretty permalinks. AS it is now, the link is changed to include the tab’s ID. so the link ends up looking like this http://lgtest.quadris.biz/quadris-gc/#link_tab-existing

    Ideally i would like to omit that last part from the URL and just keep the venue’s permalink. That is probably me being fussy though, i imagine that if i removed that from the link then when redirected the tab wouldn’t be opened by default.

    Function to perform redirect on login:

    COPY CODE
    add_filter( 'login_redirect', function ( $redirect_to, $requested_redirect_to, $user ) {
    
    global $user;
    if( isset( $user->roles) && is_array( $user->roles)) {
        if ( in_array( 'administrator', $user->roles)) {
        $redirect_to = admin_url();
        return $redirect_to;
        } elseif ( ! $requested_redirect_to ) {
            $redirect_to = wp_get_referer();
    
             return $redirect_to;
        }
    
       
       
    }
     ?>
        
        <?php if (is_user_logged_in()) : ?>
        <a href="<?php echo wp_logout_url(get_permalink()); ?>">Logout</a>
    <?php endif;
        
    }, 10, 2 );

    Generally though Laura, the redirect is working now (yay!) but if you can offer any advice on fixing the administrator redirect part and if it’s possible to clean the URL up a bit. Or if there is a way to edit the tab names so that the output is quadris-gc/#existing and not /#link_tab-existing

    Thanks for your time Laura,

    PhilB

    #168626
     Gavsta
    Participant

    I forgot to tick ‘Private reply’ and cannot edit my previous post. Please could you set my response to private! Thanks,

    Phil

    #168694
     Laura
    Moderator

    Hello, will assign the ticket to a higher support level who can help and advise you in your query.
    Thanks! ?

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #168732
     Gavsta
    Participant

    Hi,

    Thanks Laura. Like i say it is near enough working, i’d just like to clean the URL up a bit. Also, i know that Kleo has a redirect option in the theme settings so i didnt know if there was a template tag or filter that would alter Kleo’s redirect function, if there is then even better.

    I mean, that would have worked anyway but i have a lot of venue pages that i need to redirect to so i cant just set one page.

    Anyway,

    Thanks again Laura!

    PhilB

    #169099
     Gavsta
    Participant

    Hi,

    I just wanted to update and let you guys know that the client has decided not to go for forcing users to login for certain parts of the website, so this is no longer needed so i wont be working on this. I’m happy to close the ticket and save you guys time.

    Many thanks,

    PhilB

    #169166
     Radu
    Moderator

    Hi PhilB,
    Thank you for the info

    Have a nice day

    Cheers
    R.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.

Log in with your credentials

Forgot your details?