WordPress at Your Fingertips
function is not described

WC_Customer::set_role() public WC 3.0.0

Set customer's user role(s).

{} It's a method of the class: WC_Customer{}

No Hooks.

Return

null. Nothing.

Usage

$WC_Customer = new WC_Customer();
$WC_Customer->set_role( $role );
$role(mixed) (required)
User role.

Changelog

Since 3.0.0 Introduced.

Code of WC_Customer::set_role() WC 6.1.0

public function set_role( $role ) {
	global $wp_roles;

	if ( $role && ! empty( $wp_roles->roles ) && ! in_array( $role, array_keys( $wp_roles->roles ), true ) ) {
		$this->error( 'customer_invalid_role', __( 'Invalid role', 'woocommerce' ) );
	}
	$this->set_prop( 'role', $role );
}