I am using plugin for login/logout(https://wordpress.org/plugins/login-logout-menu/) navigation link to be dynamic. Once user role logged in they will redirect to specific page and functionality is working fine. For logged out it should redirect to home page for specific role. I have tried using the hooks provided but it is not working. Currently admin and normal user role logged out to the default login redirect link which is in the 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' );