Take the 2-minute tour ×
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 core.trac.wordpress.org/ticket/19898 –  Stephen Harris Aug 29 at 15:38

2 Answers 2

up vote 24 down vote accepted

Use the global $pagenow;

if ( in_array( $GLOBALS['pagenow'], array( 'wp-login.php', 'wp-register.php' ) ) )
    run_my_funky_plugin();
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

Your Answer

 
discard

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.