Change group status from hidden to public and vice versa
-
Hi all.
I’m coding a function to change group status according to number of members in that group. Groups are set to hidden if they are newly created and they can be visible for everyone until they reach a certain number of members (for instance 20 members). So I add a function in functions.php:
// Group change status. Group is visible if it has more than 20 members
function group_change_status($group_id) {$group_count = groups_get_groupmeta( $group_id, ‘total_member_count’);
if ( $group_count < 20 ) {
groups_edit_group_settings( $group_id, ‘1’, ‘hidden’ );
} else {
groups_edit_group_settings( $group_id, ‘1’, ‘public’ );
}
}
add_action( ‘groups_leave_group’,’group_change_status’ );
add_action( ‘groups_join_group’,’group_change_status’ );
add_action( ‘groups_accept_invite’,’group_change_status’ );When I do add_action to groups_leave_group, it works perfectly, that means when someone leave group to make the total number member is 19, group becomes hidden.
However the other two actions for groups_join_group and groups_accept_invite don’t work. People join the group more than 20 but they are not visible.
Can anyone help me to fix this?
Thanks
- The topic ‘Change group status from hidden to public and vice versa’ is closed to new replies.