It's random, too damn random.


wp_logout_url Code

February
13
2009
Posted by Shaibani | Tags: ,

Well as you may have seen, I’ve been changing themes quite frequently in the last few days. I decided to go back to Resurrection (my theme), and as I was looking through the comments code, I found this:

1
<p>Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="Log out of this account">Log out &raquo;</a></p>

What’s wrong with that you ask? If you’re on WordPress 2.7 (you better be), you’re gonna have a problem. In WordPress 2.7, you’ll notice there’s a wpnonce=x (x being random figures and letters) added to the logout URL. How do I get that when there’s a random figure there? Simple:

1
<p>Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo wp_logout_url(); ?>" title="Log out of this account">Log out &raquo;</a></p>

See the difference? It’s the echo wp_logout_url();. That function gives you the whole URL with the wpnounce. :-)

No related posts.

No comments yet.

Leave a Reply

Get Adobe Flash playerPlugin by wpburn.com wordpress themes