Adding users to BuddyPress private groups

In the previous section, we completed the first part of the integration with MyCred and WooCommerce. The next step is to complete the integration by connecting MyCred with BuddyPress groups. As we discussed, the requirement is to assign users to a BuddyPress private group once they reach specific number of MyCred points. So, we have to look for a way to add users to a BuddyPress group. We can either check for the documentation or use a search engine to find the appropriate implementation. BuddPress provides a function called groups_join_group to add users into a group. Let's use that function to modify the wpqpi_payment_complete function and add users to groups:

public function wpqpi_payment_complete( ...

Get WordPress Development Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.