Created
August 18, 2013 15:08
-
-
Save yursil/6262120 to your computer and use it in GitHub Desktop.
Auto enroll into group upon registration for Groups Plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add Group whenever Admin uses Gravity forms to activate them | |
add_action('gform_activate_user', 'sm_autogroup'); | |
// And / OR Add Group whenever anyone registers | |
add_action('user_register', 'sm_autogroup'); | |
function sm_autogroup($user_id) | |
{ | |
$theUser = get_userdata( $user_id ); | |
if(in_array("therolename",$theUser->roles)) | |
{ | |
$groupToAdd = Groups_Group::read_by_name("thegroupname"); | |
Groups_User_Group::create(array( "user_id" => $user_id, "group_id" => $groupToAdd->group_id )); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment