你应该能抓住这个template_redirect
或在parse_request
/ pre_get_posts
.
将一些页面(如登录名或IP地址)列入白名单,否则如果您注销,您将被锁定。
将301添加到wp_redirect
会有帮助的search engines.
// NOTE: This code has not been tested
function wpse12302015_check_user_status()
{
// a user with admin privileges? - forget about it
if(current_user_can(\'manage_options\')) {
return;
}
// whitelist some pages
if( is_page( \'login\' ) )
{
return;
}
// send them off to the new website using the current request
$url = \'http://www.example.com\' . $_SERVER[\'REQUEST_URI\'];
wp_redirect( $url, 301 ); // Moved Permanently
exit();
}
add_action( \'template_redirect\', \'wpse12302015_check_user_status\' );
The
template_redirect
看起来它没有击中login
事件。
Login Events
- [
init
] - [
widgets_init
] - [
wp_loaded
] - [
admin_init
] - [
wp_authenticate
] - [
wp_login
] - [
shutdown
]
Front End Events
- [
init
] - [
widgets_init
] - [
wp_loaded
] - [
parse_request
] - [
pre_get_posts
] - [
template_redirect
]
Admin Events
- [
init
] - [
widgets_init
] - [
wp_loaded
] - [
admin_menu
] - [
admin_init
] - [
wp_print_scripts
] - [
admin_head
] - [
admin_footer
] - [
shutdown
]