我正在使用插件进行登录/注销(https://wordpress.org/plugins/login-logout-menu/) 导航链接是动态的。一旦用户角色登录,他们将重定向到特定页面,功能正常。对于注销,应重定向到特定角色的主页。我试过使用提供的挂钩,但不起作用。当前管理员和普通用户角色已注销到wordpress中的默认登录重定向链接。
function redirect_after_logout() {
$current_user = wp_get_current_user();
$role_name = $current_user->roles[0];
if($role_name == \'employee\'){
$redirect_url = site_url();
wp_safe_redirect( $redirect_url );
exit;
}
}
add_action( \'wp_logout\', \'redirect_after_logout\' );