The WPFolks app is out on iPhone and Android. Free, no ads. Download on the App Store Get it on Google Play
Skip to main content
Login Join
Snippet · PHP

Restrict Checkout for Specific User Role

Shared by Darshit Rajyaguru · April 28, 2026 · @woocommerce_checkout_process

56 views
1 upvote
Back to Snippets

This will help to restrict/block wholesale users from checkout. Create a custom role OR use an existing (e.g., subscriber).

add_action( 'woocommerce_checkout_process', function() {

    if ( ! is_user_logged_in() ) return;
    $user = wp_get_current_user();

    if ( in_array( 'subscriber', $user->roles ) ) {
        wc_add_notice( 'You are not allowed to checkout.', 'error' );
    }
});
Know a different way to do this? Add your approach as a variation so folks can compare them side by side.
Submit a variation

0 comments