WordPress Login / Logout Link in Template

The standard WordPress Login/Logout links often suffice but when you are building custom pages then the default WordPress pages can look a little out of place on your site and therefore you may need to redirect your users to different pages and/or change the text links of those standard links (boy, I’m saying standard a lot in this post!)

WordPress login/logout link

This link directs you to the standard WordPress Login page i.e. yoursite.com/wp-login.php and features the words “Log in” and “Log out” as the hyperlinks. This will send the user to the default login page and once logged in will redirect them to the WordPress Dashboard.

WordPress Login/Logout page with custom links

This will send the user to the default login page and once logged in will redirect them back to the page they were previously on. This will send the user to the default login page and once logged in will redirect them to the WordPress Dashboard.

WordPress Login/Logout page with custom links and redirect to previous page.

This will send the user to the default login page and once logged in will redirect them back to the page they were previously on.

Custom WordPress Login/Logout pages with custom links

The following code will send the user to the page with ID of 22 to login (obviously you will need to add a login form to that page) and then will send them back to the home page when logged out.

  • Perce

    CUSTOM WORDPRESS LOGIN/LOGOUT PAGES WITH CUSTOM LINKS
    Been looking how to do that for ages today ! Many thanks for the info…

  • http://www.rayanzenner.com Ryan McGovern

    Nice post thanks

  • http://www.iamniloy.com Niloy Sarker

    brilliant .

    it’s working :)
    I think i should use it in my new plugin .
    Thanks

  • tom

    Its not good code. After logged out its redirect to 1st post. when ur on homepage.

  • http://www.datearena.com Datesarena.com

    nice

  • http://www.datearena.com Datesarena.com

    Works very well

  • wordpress

    WordPress Plugins we use

    Each WP project varies and so that has a knock on effect on what plugins we use so this is by no means a definitive list, but merely our favourites that get used quite a lot

  • wordpress-login-logout-link

    10 Useful WordPress Admin plugins

    There’s a lot of plugins available for Wordpress and you often miss out on some of the gems, purely because there’s so many to trawl through and you might not know what you’re after until you stumble upon it. Here we’re focussing on those plugins that can help with the behind the scenes part of Wordpress – the CMS Admin.

  • wordpress-login-logout-link

    Useful WordPress Snippets

    There’s lots and lots of things to remember when using WordPress and you can’t remember everything. Here’s a list of useful little snippets that I’ll keep on adding to over time. To be honest it’s more for my record as it’s stuff that I use regularly but thought I’d add for all to share. WordPress […]

  • wordpress-login-logout-link

    Secure your WordPress Blog

    When anything gets big and popular there are always unscrupulous folk out there wanting to hack your site or as they put it showing you the security downfalls of the software. With that in mind you’ll need to secure your WordPress Site so they can’t get in and ruin your site. There’s a number of […]

  • dare-to-think-square

    Forward your emails to one address

    Earlier we spoke about how to redirect domains to your main site. To add to this it’s worth setting up a forward/redirect for all emails that people may send to those other urls. Using cPanel we’ll show you how. Login to your websites’ cPanel and locate the “Default Address” section. From there you will see […]