标签:queue sse url cas 动作 lte exists page register
在使用Wordpress制作主题之后,不想要他自带的登陆页面以及地址。
//在主题根目录下新建page-login.php,通过action获取用户动作,然后进行不同的处理。
//当然也可以只把login动作的代码放里面,其余再新建page-register.php等页面。
$action = isset($_REQUEST[‘action‘]) ? $_REQUEST[‘action‘] : ‘login‘;
global $wpdb, $user_ID;
switch ($action) {
case ‘logout‘:
if ($user_ID) {
wp_logout();
$redirect_to = apply_filters(‘logout_redirect‘, $redirect_to, $requested_redirect_to, $user);
wp_safe_redirect($redirect_to);
}
exit();
case ‘forget‘:
if ($user_ID) {
wp_redirect(get_bloginfo(‘url‘));
} else {
//在这里写忘记密码的处理过程
}
exit();
case ‘reset‘:
if ($user_ID) {
//这里写重置密码的处理过程
} else {
wp_redirect(wselibrary_getloginurl());
}
exit();
case ‘register‘:
if ($user_ID) {
wp_redirect(get_bloginfo(‘url‘));
} else {
//在这里写用户注册的处理过程
}
exit();
case ‘login‘:
default:
if ($user_ID) {
wp_redirect(get_bloginfo(‘url‘));
} else {
//这里写用户登陆的处理过程
}
exit();
}
//原理其实很简单,就是让用户访问自带登陆页面时直接跳转到指定页面
if (!function_exists(‘login_protection‘)) {
function login_protection()
{
//如果有需要,你可以给自己一个访问的途径
if ($_GET[‘superuser‘] != ‘password‘) header(‘Location: /index.php/login‘);
//当然你也可以禁止所有人访问
//header(‘Location: /index.php/login‘);
}
add_action(‘login_enqueue_scripts‘,‘login_protection‘);
}
标签:queue sse url cas 动作 lte exists page register
原文地址:https://www.cnblogs.com/jerryqi/p/9728729.html