// Get the value for field 5 $user = $db->query_first(" SELECT field5 FROM " . TABLE_PREFIX . "userfield WHERE userid = " . $vbulletin->userinfo['userid'] . " "); if ($user['field5'] == 'male') { $userdata->set('usergroupid', 9); } else if ($user['field5'] == 'female') { $userdata->set('usergroupid', 10); } $userdata->save();