Skip to content
Snippets Groups Projects
Commit b76b82e1 authored by Matthew Juhl's avatar Matthew Juhl
Browse files

Add user to college group automatically on profile update.

parent 23651f92
No related branches found
No related tags found
No related merge requests found
......@@ -16,5 +16,51 @@ function unl_theme_init(){
register_elgg_event_handler('init','system','unl_theme_init');
function unl_profileupdate () {
/**
* Enroll user in group for their selected college when possible.
**/
$college_groups_guids = array();
$college_groups_guids['Engineering'] = 1091;
$college_groups_guids['Journalism and Mass Communications']= 6179;
$college_groups_guids['Business Administration'] = 905;
$college_groups_guids['Arts and Sciences'] = 5358;
$college_groups_guids['Hixson-Lied College of Fine and Performing Arts'] = 753;
$college_groups_guids['Law'] = 6949;
$college_groups_guids['Agricultural Sciences and Natural Resources'] = 6950;
$college_groups_guids['Architecture'] = 6951;
$college_groups_guids['Education and Human Sciences'] = $college_groups_guids['Human Resources and Family Sciences'] = $college_groups_guids['Teachers College'] = 6952;
/* ADD OTHER COLLEGE GROUPS HERE */
$data = form_get_profile_data_from_form_post();
$college = $data['profile_college']->value;
$user_guid = get_input('user_guid', get_loggedin_userid());
$user = get_entity($user_guid);
if (isset($college_groups_guids[$college])) {
$group_guid = $college_groups_guids[$college];
$group = get_entity($group_guid);
if ($group->join($user))
{
system_message(elgg_echo("groups:joined"));
// Remove any invite or join request flags
remove_entity_relationship($group->guid, 'invited', $user->guid);
remove_entity_relationship($user->guid, 'membership_request', $group->guid);
// add to river
add_to_river('river/group/create','join',$user->guid,$group->guid);
}
}
}
register_elgg_event_handler('profileupdate','all','unl_profileupdate');
register_action("login",false,$CONFIG->pluginspath. "unl_theme/actions/login.php");
?>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment