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. Go to B2BKing->Tools->User Editor and use the "Move all users to group" button:

This is an easy way to move a large number of users and is 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 two meta keys:

  • b2bking_b2buser

The value should be yes for B2B users and no for B2C or other users.

  • b2bking_customergroup

The value should be the group ID (e.g. 253, 13, 19, etc.).

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

Here is an example of how this all looks:

The example above is taken from the database. The user is a B2B user and belongs to the group with ID 14. If we want to see which 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