WordPress.org

Ready to get started?Download WordPress

Forums

Groups
[resolved] Automatically join users to group at registration (2 posts)

  1. andyredsox
    Member
    Posted 1 year ago #

    Great plugin. Really quite useful, thank you.

    In reading the Forum posts it appears you can use the shortcodes [groups_join] and [groups_leave] to set it up so that when someone registers they can self select a group to join (or leave).

    What I need to be able to do is auto-join someone to a group based on registration information such as geography - derived from the state that they live in - where each state is mapped to a group. The state groups are already defined and there is content designated for them, I just want to make the group assignment happen easily behind the scenes based on the address the user provides.

    Is there a recommended approach for adding this kind of group auto-join logic?

    http://wordpress.org/extend/plugins/groups/

  2. itthinx
    Member
    Plugin Author

    Posted 1 year ago #

    Hi there,

    Assuming that the states have their groups mapped by name and that the information is provided at registration, you would basically need to check the state (user meta I would suppose) and then use

    if ( $group = Groups_Group::read_by_name( $state ) ) {
        Group_User_Group::create(array( 'user_id' => $user_id, 'group_id' => $group->group_id ) );
    }

    to add the user to the group.

    You would have to hook into user_register to get the $state from the user's meta.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic