WordPress.org

Forums

[resolved] Own logout form in sidebar doesn´t work since 2.7 (10 posts)

  1. infected
    Member
    Posted 4 years ago #

    Hi!

    I integrated a own login/logout form into my sidebar. Since i updated to 2.7 the logout function doesn´t work properly. After i click on logout i´ll be redirected to a page where is displayed something like "You are attempt to logout. Please try again." The code i use in my sidebar looks like this:

    Sorry, code looks broken if i paste it here. Please take a look at this page. Thanks.

    After clicking on "Try again." i will be redirected to the frontpage and i am still logged in. Does anybody know what´s the problem? Is it a bug in WP 2.7 or is there something going wrong with my code?

    Maybe someone of you guys know how to fix it?

  2. infected
    Member
    Posted 4 years ago #

    *Push*

    Can´t get it working...
    If i choosed the wrong forum for my problem please move this post...

    I hope someone can help me with this.

  3. Branch
    Member
    Posted 4 years ago #

    Yeah, this doesn't seem to be documented yet, like a lot of other things. There's a new function in 2.7 that generates log-out links and inserts the 'nonce' now required. So, down where your log-out link url is, replace the whole thing with this:

    echo wp_logout_url();

    If you want to do a redirect back to the page you were on, use this:

    <?php echo wp_logout_url(); ?><?php echo '&redirect_to='.$_SERVER['REQUEST_URI']; ?>

    It took me a while to find this one, too!

  4. infected
    Member
    Posted 4 years ago #

    Oh no! :) Found it by myself 30 minutes ago, and now i read your post :) But thanks! I googled for logout changes in 2.7 and found the codex entry about the new template tag. After a bit of trying i could get it work. Was it announced anywhere? I think not... Well i changed the two lines of my code to <li><a href="<?php echo wp_logout_url('/wp-login.php?action=logout&amp;redirect_to=' . $_SERVER['REQUEST_URI']); ?>" title="Logout">Logout</a></li>

    But thanks again for your reply. I was searching for the reason of this issue a few hours...

  5. DJ Allyn
    Member
    Posted 4 years ago #

    I am using Login Anywhere, and for some reason I can't get your fix to work.

    The original code is this:

    echo "<a href='"; echo get_settings('siteurl') . '/wp-login.php?action=logout&redirect_to=' . $_SERVER['REQUEST_URI']; echo "'>Logout</a>

    I have tried everything.

  6. HappyApple
    Member
    Posted 4 years ago #

    Hello, I can't seem to find 'Login Anywhere," So I can't help you out there. I recommend using Ajax Login. You will need to use the fix mentioned in this topic in order for it to work with WordPress 2.7 .

    Edit "al_template.php" in the ajax-login folder,

    Look for this:

    /*******
      This part is drawn when user IS logged in.
      *******/

    Below it you will find the following code:

    <div>
    <h3><?php echo $user_identity; ?></h3>
    <hr/>
    <div>
        <a href="<?php echo get_settings('siteurl') . '/wp-login.php?action=logout&amp;redirect_to=' . $_SERVER['REQUEST_URI']; ?>"><?php _e('Logout'); ?></a>
    </div>
    </div>

    Change it to look like this:

    <div>
    <h3><?php echo $user_identity; ?></h3>
    <hr/>
    <div>
        <a href="<?php echo wp_logout_url('/wp-login.php?action=logout&amp;redirect_to=' . $_SERVER['REQUEST_URI']); ?>" title="Logout">Logout</a>
    </div>
    </div>

    It should now work, hope this help. ;)

  7. krescent2
    Member
    Posted 4 years ago #

    how do i apply the
    <?php echo wp_logout_url(); ?><?php echo '&redirect_to='.$_SERVER['REQUEST_URI']; ?>

    do i apply it on the theme comments.php?

    please help, thanks

  8. krescent2
    Member
    Posted 4 years ago #

    my comments.php has code like this
    <div class="logged"><?php echo ot_lang( 'logged_in' ); ?> <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a> <img src="<?php bloginfo('stylesheet_directory'); ?>/img/icons/user.gif" alt="<?php echo ot_lang( 'logged_in' ); ?>" border="0" style="margin:0;" class="valign-img" />&nbsp;&nbsp; <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="<?php echo ot_lang( 'user_logout' ); ?>"><?php echo ot_lang( 'user_logout' ); ?></a> <img src="<?php bloginfo('stylesheet_directory'); ?>/img/icons/logout.gif" alt="<?php comments_number('');?> <?php echo ot_lang( 'comments_word' ); ?>" border="0" style="margin:0;" class="valign-img" /></div>

    please tell me where i have to change it, very new to wordpress

  9. HappyApple
    Member
    Posted 4 years ago #

    Hello krescent2. :D If you are using AJAX-Login, then you need to apply the code in the file named "al_template.php" in the wp-content/plugins/ajax-login/ directory.

    Look at my post above for more detail. ;)

  10. aytacengin
    Member
    Posted 3 years ago #

    Hello Friends,

    Main problem is wordpress versions.

    Use this codes ;) :

    <a href="'.wp_logout_url(get_option('siteurl')).'" title="'.$usp_language['logout'].'" >'.$usp_language['logout'].'</a>

    Good Luck

    For more informations Click Here

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.