• Resolved ananddevops

    (@ananddevops)


    Hello,

    I am using the social login on my site – here . It shouws the login button as expected – See image .

    I have a redirection url post the login – See image.

    But when the user is already logged in the Login button does not show. Infact thats ok, but instead, I want to prompt the user that they are already logged in and they should click on the Redirection URL – See Image

    Is there way to achieve that?

    Thanks,
    Anand

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Heateor Support

    (@heateor)

    Hi,

    You cannot use the condition in the shortcode or in the content of the web page to check if a user is logged in or not. So, you need to create a WordPress Page template (I am assuming you are familiar with the WordPress coding) where you can show the social login icon to a non-logged in user using the shortcode and the redirection link to the logged in users.

    Thread Starter ananddevops

    (@ananddevops)

    @heateor Much Appreciate the input, its very helpful. Although I am not familiar with wordpress development, I will surely read up and give this a try.

    Thread Starter ananddevops

    (@ananddevops)

    @heateor I looked up the Page Template info as suggested. If the login was in wp-login.php a code as below should have worked:

    <?php if ( is_user_logged_in() ) { 
       wp_loginout();
    } else {
        echo 'User already logged in';
        wp_loginout();
    } ?>

    But in my case I am using a custom Elementor page and using the Social Login function. So wp_loginout(); will not work. Instead what function should I use?

    Thanks,
    Anand

    Thread Starter ananddevops

    (@ananddevops)

    @heateor any suggestions on the above?

    Thanks

    Plugin Author Heateor Support

    (@heateor)

    Something like the following would work.

    <?php if ( is_user_logged_in() ) { 
       // User is already logged in, redirect user
       wp_redirect( 'REDIRECTION_URL' );
    } else {
       // user is not logged in, show social login icons
       echo do_shortcode( '[TheChamp-Login]' );
    } ?>

    Replace REDIRECTION_URL in above mentioned code with the full URL where you want to redirect the user if they are already logged in.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Show Redirection link when user aleady logged in’ is closed to new replies.