您正在使用筛选器wrong. 如果你有不止一个@param
, 然后,您必须在添加过滤器时声明它们。
function wpse40745_redirect_on_login( $redirect_to, isset( $_REQUEST[\'redirect_to\'] ), $user )
{
# uncomment the following line if it\'s not working and replace $user->roles[0] with something that works
// echo \'<pre>\'; print_r( $user ); echo \'</pre>\'; exit;
if ( in_array( $user->roles[0], array( \'contributer\', \'whatever_other_role ) ) )
return home_url();
return $redirect_to;
}
add_filter( \'login_redirect\', \'wpse40745_redirect_on_login\', 20, 3 );