WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Automatically join users to group at registration

[Resolved] Automatically join users to group at registration

  • 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/

Viewing 1 replies (of 1 total)
  • Plugin Author itthinx

    @itthinx

    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.

Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] Automatically join users to group at registration’ is closed to new replies.