Hi,
Thanks so much for helping me for previous problems and I’m really appreciated that.
I just wonder that is there any way to add a user to several groups at the same time when I create this user account?
Could you provide me some code snippet about this function? I know probably it will be in the bp-custom.php.
Thank you very much.
Hi Dandy,
Please try the following code in your bp-custom.php file
function buddydev_add_user_to_group( $user_id ) { if ( ! function_exists( 'buddypress' ) || ! bp_is_active('groups' ) ) { return; } $group_ids = array(1,3,4,7); //ids of groups you want to add new user as member foreach ($group_ids as $group_id ) { groups_join_group( $group_id, $user_id ); } } add_action( 'user_register', 'buddydev_add_user_to_group', 10, 1 );
and let me know if it works or not.
Thank you
Ravi
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic.
This topic is: not resolved