Site icon Qaisar Satti's Blogs

WooCommerce get current user role

WooCommerce get current user role

Today we talk about WooCommerce or WordPress get the current user role. In this tutorial, We focus on getting the current user group for example you need to match or check what is current user role. On the basis of that need to give a discount or show some extra text.

Let’s start with our example.

// get Current User Role
$currentUser      = wp_get_current_user();
$currentUserRole = $currentUser->roles[0];
Exit mobile version