Skip to:
Content
Pages
Categories
Search
Top
Bottom

Check to see if group is full


  • Nickguidomedia
    Participant

    @nickguidomedia

    so i have the limit group plugin installed.

    I have a use case where users are getting added to a group based on their zipcode during registration. This is working fine as it stands. However, the client wants these zip code groups to be 150 people limit. so for instance lets say i have a 12345 zip code group. user registers , group is full, it creates a new group 12345-1 and adds user to new group. if 12345-1 fills up group 12345-2 is made and so forth.

    any ideas?

Viewing 5 replies - 1 through 5 (of 5 total)

  • Henry Wright
    Moderator

    @henrywright

    Hi @nickguidomedia

    My first thought was to get the member count of the relevant group during each user registration.

    That can be done with groups_get_total_member_count( $group_id );.

    You’d need to check this figure is less or equal to 150 and if it isn’t, you’d need to add the user to an over-spill group, creating a new one if necessary.

    As you mentioned users are added to a group automatically during registration.

    The bp_core_signup_user hook fires at the end of the registration process so could hook all your code for the above to that. That hook gives you access to $user_id, $user_login, $user_password, $user_email and $usermeta, so you should be able to get all the info you need from those. For example:

    function my_func( $user_id, $user_login, $user_password, $user_email, $usermeta ) {
        // Write your code here.
    }
    add_action( 'bp_core_signup_user', 'my_func', 10, 5 );

    Hope this helps.


    Nickguidomedia
    Participant

    @nickguidomedia

    question on the $usermeta , do you know how this returns? can i get the xprofile_get_field_data( “zipcode” ); in a similar fashion from the $usermeta?


    Henry Wright
    Moderator

    @henrywright

    Does var_dump( $usermeta ); tell you anything? I think it’ll probably be an array of stuff like the user’s password, profile field IDs etc


    Nickguidomedia
    Participant

    @nickguidomedia

    ended up going about this completely different actually. was easy to just pass $user_id, $xprofile_data
    to my function.

    and call $zipcode = xprofile_get_field_data(7, $user_id);

    from there i was easily able to do the rest.


    Henry Wright
    Moderator

    @henrywright

    Great stuff 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Check to see if group is full’ is closed to new replies.
Skip to toolbar