How to check if your current page is the wp-login.php page

I realized this morning that my TMM Maintenance Mode WordPress plugin had a bug that was causing the wp-login.php page to be inaccessible. The solution was to write a simple function that checks whether or not we’re currently on a login page, and then add a call to that function in my code. Here’s the function:

function is_login_page() {
    return in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php'));

From there, I called “is_login_page()” in my code. You can see the before-and-after code update on Github here.

Now I’m able to access my login page! *and there was much rejoicing*

wordpress login page
My login page

Is this helpful?


Many thanks to Bainternet for this solution.

Toby Cryns

Toby Cryns is a freelance CTO, expert WordPress consultant, and teacher.

He offers free advice to improve your freelance biz.

He also publishes small droppings every now and then to and

Follow Toby's contributions on Github and