1
我在WordPress上,我試圖在登錄後重定向用戶,但只有當他們從某個頁面登錄(slug是'升級 - 現在黃金級教練')僅當用戶從某個頁面登錄後,我如何在登錄後重定向?
這裏是我到目前爲止:
function my_login_redirect($redirect_to, $request, $user) {
//did they try to login from this page?
if ($request == "upgrade-now-gold-class-coaching") {
//is there a user to check?
if (isset($user->roles) && is_array($user->roles)) {
//check for admins
if (in_array('administrator', $user->roles)) {
// redirect them to the default place
return $redirect_to;
} else {
return "https://www.drewbairdfitness.com/11674-2/";
}
} else {
return $redirect_to;
}
} else {
return $redirect_to;
}
}
add_filter('login_redirect', 'my_login_redirect', 10, 3);
謝謝!
你把你的登錄表單放在哪裏?是在你的某個頁面,或者你仍然使用默認的登錄表單(wp-admin/wp-login.php)? – Jevuska
它在不同的頁面上;它實際上是'/升級現在黃金級教練/' - 我打算有多個登錄頁面;並希望他們每個人登錄後重定向到別的地方 –