[英]Redirect non admin user on specific page in wordpress
我已經通過google找到了一篇文章,將非管理員用戶的wordpress登錄重定向重定向到了首頁。 但是在那篇文章中,它使用功能而不是URL定向到網站的主頁。 但是我想在項目的特定頁面上重定向。 我使用的代碼是
function admin_login_redirect( $redirect_to, $request, $user )
{
global $user;
if( isset( $user->roles ) && is_array( $user->roles ) ) {
if( in_array( "administrator", $user->roles ) ) {
return $redirect_to;
} else {
return home_url();
}
}
else
{
return $redirect_to;
}
}
add_filter("login_redirect", "admin_login_redirect", 10, 3);
如何重定向到特定頁面...
@詹姆斯·瓊斯的需求在這里是解決方案
您可以使用get_permalink( page_id )
代替home_url()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.