• Hi

    I hv problem with logout.On click logout its go to php admin insted home page.Here is code below:

    <?php
       if (is_user_logged_in()) {
          $user = wp_get_current_user();
          echo 'Hi <strong><a href="#" rel="nofollow">'.$user->display_name.'</a></strong> | <a href="/wp-login.php?action=logout&quot;">Logout</a>';
    
       } else { ?>
          Please <strong><?php wp_loginout(); ?></strong>
          or <a href="<?php bloginfo('url') ?>/wp-login.php?action=register"> <strong>Register</strong></a>
    
    <?php }?>

    Please help me…

Viewing 7 replies - 1 through 7 (of 7 total)
  • Anjara

    (@hiteshanjara)

    Hey,

    Hope this link will help you: https://codex.www.ads-software.com/Function_Reference/wp_logout_url

    Hitesh Anjara

    Thread Starter gopalb123

    (@gopalb123)

    Hi Hitesh,

    thanx for your quick action…alread i had tried several our in codex but i’m not resolved the problem, so i post this forum…

    I find the problem in code”<a href="/wp-login.php?action=logout&quot;">Logout</a>';” before /wp-login.php need to insert bloginfo(‘url’) because i write fullpath i.e https://localhost/kow/wp-login.php and it’s work. But i dont want to write fullpath or modify core file… if any solution you have please share with me…
    thanx

    Anjara

    (@hiteshanjara)

    Are you editing “wp-login.php” file?

    Please put here your code so that I can clearly see the problem and will try to solve it..

    Thread Starter gopalb123

    (@gopalb123)

    No I’m not editing “wp-login.php.

    <li>
          <?php
       if (is_user_logged_in()) {
          $user = wp_get_current_user();
          echo 'Welcome <strong><a href="https://localhost/kow/wp-admin/profile.php" rel="nofollow">'.$user->user_firstname.'</a></strong> | <a  href="https://localhost/kow/wp-login.php?action=logout&quot;">Logout</a>';
    
       } else { ?>
          Please <strong><?php wp_loginout(); ?></strong>
          or <a href="<?php bloginfo('url') ?>/wp-login.php?action=register"> <strong>Register</strong></a>
    
    <?php }?>
    
    </li>

    Also I need to add avatar after user name…

    Anjara

    (@hiteshanjara)

    Try this –

    <li>
          <?php
       if (is_user_logged_in()) {
          $user = wp_get_current_user();
          echo 'Welcome <strong><a href="https://localhost/kow/wp-admin/profile.php" rel="nofollow">'.$user->user_firstname.'</a></strong> | <a href="<?php echo wp_logout_url( home_url() ); ?>" title="Logout">Logout</a>';
       } else { ?>
          Please <strong><?php wp_loginout(); ?></strong>
          or <a href="<?php bloginfo('url') ?>/wp-login.php?action=register"> <strong>Register</strong></a>
    
    <?php }?>
    
    </li>
    Thread Starter gopalb123

    (@gopalb123)

    thanx..

    I hv tried it before.. its not working…generate 403 page…

    Anjara

    (@hiteshanjara)

    Strange Issue..

    it occurs may cause of .htacces file or my be permission issue at your local server..

    I think your code is correct, you need to check other things for the same..

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Login Logout problem’ is closed to new replies.