Hi,
You can hide the bar by using a filter hook. Below is the code snippet that should work:
add_filter('fsl_min_amount', function ($amount) {
$user = wp_get_current_user();
if (in_array('role_name', (array) $user->roles)) {
$amount = null;
}
return $amount;
});
Just replace role_name with the role you want to target, such as ‘subscriber’, ‘editor’, or any custom role.
Best regards
Hi @marinmatosevic, thank you for the snippet! This does work for a single role, but I need to apply it to multiple user roles. Can you assist? Thanks in advance.
Here’s the modified code snippet to target multiple user roles:
add_filter('fsl_min_amount', function ($amount) {
$user = wp_get_current_user();
// List the roles you want to target in the array below.
$roles_to_hide_for = ['role_1', 'role_2', 'role_3'];
if (array_intersect($roles_to_hide_for, (array) $user->roles)) {
$amount = null;
}
return $amount;
});
If you’re also using a gift progress bar and want to hide it, you’ll need to use the fsl_progress_bar_html hook instead. However, if you only have the free shipping progress bar, then it’s perfectly fine to use the fsl_min_amount hook as shown above.
Great! I’m glad that I was able to help you. 🙂 If you’re enjoying the plugin, we would be incredibly grateful if you could spare a moment to leave a review. Your feedback is valuable to us. Thank you!