可能只是一个拼写错误。尝试写入:
\\u user\\u logged\\u是否已登录()
看起来好像忘了()
UPDATE:
因为您不想在每次加载页面时重定向,所以必须挂接重定向。我在此举一个例子(摘自文档并略加编辑):
<?php
function daro_login_redirect( $redirect_to, $request, $user ) {
//is there a user to check?
if ( isset( $user->roles ) && is_array( $user->roles ) ) {
//check for admins
// edit this part accordingly to your login needs:
// maybe you can skip the else statement
if ( in_array( \'administrator\', $user->roles ) ) {
// redirect them to the default place
return $redirect_to;
} else {
return home_url();
}
} else {
return $redirect_to;
}
}
add_filter( \'login_redirect\', \'daro_login_redirect\', 10, 3 );