I'm trying to change the login url from wp-login.php to simply 'login'. I'd been looking through another plugins source to find ways of doing it.
Some of the applicable parts that I've got so far:
register_activation_hook( __FILE__, 'my_plugin_activate' );
register_deactivation_hook( __FILE__, 'my_plugin_deactivate' );
add_action( 'init', 'my_plugin_rewrite' );
add_action( 'login_init', 'my_plugin_login_init' );
add_action( 'template_redirect', 'my_plugin_display' );
function my_plugin_activate() {
add_rewrite_tag( '%login%', '([^/]+)');
add_permastruct( 'login', '/%login%' );
flush_rewrite_rules();
}
function my_plugin_login_init() {
if ( '/wp-login.php' == $_SERVER['PHP_SELF'] ) {
header( 'HTTP/1.0 404 Not Found' );
global $wp_query;
$wp_query->set_404();
require TEMPLATEPATH . '/404.php';
exit;
}
}
function my_plugin_display() {
global $wp_query;
switch( $wp_query->query_vars['pagename'] ) {
case 'login' :
include( ABSPATH . '/wp-login.php' );
exit;
break;
}
}
The problem I'm having is in the "my_plugin_display" function.
$wp_query->query_vars['pagename'] happens to be empty. How can I test if the url is at /login? Is this the right hook to use?