Skip to main content
Login Join
Snippet · PHP

Restrict Checkout for Specific User Role

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

18 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' );
    }
});