I wanna automatically add new registered user to corresponding group by Buddypress.
Here is my code put in the theme's functions.
function automatic_group_membership( $user_id ) {
if( !$user_id ) return false;
$join_group = xprofile_get_field_data(2, $user_id); // 2 is xprofile field_id
// conditionnal
if ($join_group == "Group1") // Group Name
$group_id = 3; // Group id
// action
groups_accept_invite( $user_id, $group_id );
}
add_action( 'bp_core_activated_user', 'automatic_group_membership' );
But it doesn't work.
How can I figure out this problem?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire