Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

How can I check if the current page is wp-login.php or wp-signup.php ?

Are there more elegant solutions than using $_SERVER['REQUEST_URI'] ?

share|improve this question
For reference there is related trac discussion here – Stephen Harris Aug 29 '14 at 15:38

3 Answers 3

up vote 29 down vote accepted

Use the global $pagenow;

if ( in_array( $GLOBALS['pagenow'], array( 'wp-login.php', 'wp-register.php' ) ) )
share|improve this answer

$GLOBALS['pagenow'] doesn't work, use $_SERVER['PHP_SELF'].

if ( in_array( $_SERVER['PHP_SELF'], array( '/wp-login.php', '/wp-register.php' ) ) ){
    // do something.

and if your wordpress is not installed in the web root folder, you should use some params like YOUR_WP_PATH/wp-login.php to replace the elements in array.

share|improve this answer

I am only interested in register page, not in login page. So this might not be wanted by everybody.

$GLOBALS['pagenow'] returns index.php for me. Maybe because of buddypress or my theme.

So I used


If you inspect the body of the registration page, it also has the ID as well, so if it says page-id-4906, you can use it this way if it works better:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.