Okay
  Public Ticket #2922013
Changing Subaccount Default Role
Closed

Comments

  •  3
    Kevin Cross started the conversation

    Hi,

    Is it possible to change the default role for newly created subaccounts from "Customer" to something else?

    Thanks,

  •  2,218
    WebWizards replied

    Hi Kevin,

    Yes, you can do that with a PHP code snippet. 

    The snippet is:

    add_action('b2bking_after_subaccount_created', function($user_id){
        $userobj = new WP_User($user_id);
        $userobj->set_role('editor');
    }, 10, 1);
    

    In the above, replace "editor" with any role that you want.

    You can add the above to functions.php or by using our guide here https://woocommerce-b2b-plugin.com/docs/how-to-add-a-snippet-php-or-js/


    Kind regards,
    Stefan