Add user to group |

Looking at your core code, I think I may have found what I’m looking for:


Would that work?

Hello @veryaca

Yes, you are basically correct. This implementation is unfortunately very old and a bit tricky, so you have to be aware of something:

  • In the first parameter you pass the ID of the user
  • In the second parameter you have to pass an array of usergroup IDs of which the user should be a member of

Take into account, that this has to be the full list. So for example if the user currently belongs to group 1,2,3 and you now pass 4 to it, the user will not belong to 1,2,3 anymore. Instead, you have to pass 1,2,3,4 to it.

Confusing, I know, and I should rewrite that one day.


This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer