WC_Customer::set_role()
Set customer's user role(s).
Method of the class: WC_Customer{}
No Hooks.
Return
null
. Nothing (null).
Usage
$WC_Customer = new WC_Customer(); $WC_Customer->set_role( $role );
- $role(mixed) (required)
- User role.
Changelog
Since 3.0.0 | Introduced. |
WC_Customer::set_role() WC Customer::set role code WC 9.4.2
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 ); }