In order to change the template based on specific user roles have a look at below filter code example.
/** * Change template name based on user role. * Make sure to create custom templates with the correct names or the templates won't be found. * * @param string $template_name template name. * @param string $template_type template type like global or simple. * @param int $order_id WC Order ID. * * @return string */ function change_template_based_on_user_role( $template_name, $template_type, $order_id ) { $template_name = 'nonsoci'; $user = wp_get_current_user(); if ( in_array( 'socio', (array) $user->roles, true ) ) { $template_name = 'soci'; } elseif ( in_array( 'ospite', (array) $user->roles, true ) ) { $template_name = 'ospiti'; } return $template_name; } add_filter( 'wpi_template_name', 'change_template_based_on_user_role', 10, 3 );