Set user group programmatically / during import / in bulk / with scripts

Move all users to a group #

First of all, if you want to move all users to a group, such as the site's B2B group, there is a simple way to do it, by going to B2BKing->Tools->User Editor and using the button "Move all users to group":

This is an easy way to move a large number of users, especially useful when you first set up the site.

Move Users via Bulk Actions #

Another option you can use to move users is the "Bulk actions" functionality on the Users page:

When opened, you will see options for B2C, as well as for each B2B group:

Set Group Programmatically / in Bulk #

To set a user's group all you have to do is set 2 meta keys:

  • b2bking_b2buser

Value should be yes for b2b users and no for b2c or other users

  • b2bking_customergroup

Value should be the group id (e.g. 253, 13, 19, etc).

You can get the group ID by going to B2BKing->Groups->Business Groups and clicking on the group. The Number in the URL is the group ID.

Example how this all looks:

The example above is taken from the database. The user is a b2b user and is part of the group with ID 14. If we want to see what group that is, we go to Groups and find the one with 14 in the URL:

This is useful if you are importing a large number of users. For example if you are importing users with a tool such as WP ALL IMPORT, you can set these 2 meta keys during import and the users will be added to the respective group.

Powered by BetterDocs