I found a little article on how to create a custom WordPress Login page and I am wondering if this technique/practice is safe to use?
The article: http://blog.caercam.org/2012/09/21/wordpress-login-page-complete-redesign/
I have tried this technique but the Logout function stopped working in wordpress and if i write the wrong account username or password and click login it redirects me to the old login page is there a way to fix these problems?
I am using all the same code as in the article.
You have in many ways already answered your question: the technique described in the article is not going to be reliable. What you might not have worked out is “why”.
The code uses relative URLS…
… which are nearly always unreliable in WordPress context. That won’t work if the site is installed in a directory so that the login url is at
www.example.com/directory/wp-login.php
.Second, the code uses
wp-login.php
as the form action (notsite_url('wp-login.php')
, please note, or evenwp_login_url()
which would be correct), meaning that when you submit the form you go to the old login page for processing. If something goes wrong, that page is where you end up.Third, the
site_url
regex
hack will only work if you usesite_url
or functions that usesite_url
. It won’t work if a plugin or theme does not use those functions, nor will it work if someone ( as I usually do ) just typeswp-login.php
into the address bar.Fourth,
regex
ingsite_url
is not the way to go. You are runningregex
every time that function is used. How many times is that going to used for a login link? Less than 1%? Very wasteful.A better hook would be
login_url
, which is made for this circumstance.Basically, this is a very superficial login page hack, not a “WordPress Login page complete redesign”. There are better ways to customize your login page, the most straightforward being to use the actions and filters on the login page itself. If you choose to use a completely different page that
wp-login.php
you will need to duplicate most of the default functionality as that page has both functions and rawHTML
and isn’t easily included in other pages without making a mess.