我试图强制将 wordpress 仪表板部分作为所有用户的欢迎消息,但失败了。有没有人在订阅者登录时强制使用仪表板的功能?
// Redirect admin to the dashboard and other users elsewhere
add_filter( 'login_redirect', 'my_login_redirect', 10, 3 );
function my_login_redirect( $redirect_to, $request, $user ) {
// Is there a user?
if ( is_array( $user->roles ) ) {
// Is it an administrator?
if ( in_array( 'administrator', $user->roles ) )
return home_url( '/wp-admin/' );
else
return home_url();
// return get_permalink( 83 );
}
}