Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Change the role assigned to customers created by WooCommerce.
- * This specific example sets the role to "business_customer" when both a company
- * name and a VAT number are passed during the registration.
- * Requested by Johankat Roggen-Backwaren Nielsen.
- *
- * Need help customising the code for your need? Hire us on Codeable: http://bit.ly/codeable_discount_aelia
- *
- * @param array customer_data The original customer data.
- * @return array The customer data, with the new role to assign to the client.
- *
- * @author Aelia
- * @link https://aelia.co
- * @link https://www.facebook.com/groups/woohelp/permalink/2043265479233230/
- */
- add_filter('woocommerce_new_customer_data', function($customer_data) {
- if(!empty($_POST['billing_company']) && !empty($_POST['vat_number'])) {
- $customer_data['role'] = 'business_customer';
- }
- return $customer_data;
- }, 10, 1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement