Skip to:
Content
Pages
Categories
Search
Top
Bottom

Change group status from hidden to public and vice versa


  • Minh Tran
    Participant

    @minhtran

    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

Viewing 1 replies (of 1 total)

  • Minh Tran
    Participant

    @minhtran

    Moreover, if a group is set public by admin and less than 20 members (let say 10 members), it becomes hidden if 1 more member join group (total 11 members), that means the way to change from public to hidden is ok. But changing from hidden to public may be required more, can anyone help me?

    Thanks

Viewing 1 replies (of 1 total)
  • The topic ‘Change group status from hidden to public and vice versa’ is closed to new replies.
Skip to toolbar