great,
Below is my plugin code, what it does is as soon as user fills the profile field "X" , it validates it via an API call, if correct then changes the primary usergroup of the user to registered members from novice and adds a membergroup which gives user privelages to access the special forum:
PHP Code:
global $vbulletin,$userdata;
if ($this->setfields["field7"])
{
$json_results = file_get_contents('some API URL'.$this->userfield["field7"].'.json');
$results=json_decode($json_results, true);
foreach($result as $res){
$itemid=$res->item_id;
$purchaser=$res->buyer;break;
}
if($purchaser == $this->userfield["field5"] && $item_id == 'CUSTOMID')
if(!in_array($vbulletin->userinfo['usergroupid'], array(2,6,7))){
$userdata->set('usergroupid',2);
$membergroupids = $userdata->fetch_field('membergroupids');
if ($membergroupids)
{
if(strpos($membergroupids, ', 9,') == false)
$membergroupids = $membergroupids . ", 9";
}
else{ $membergroupids = 9;
}
$userdata->set('membergroupids', $membergroupids);
}
}else{
$this->error('Invalid Purchase Code !');
}
}
--------------- Added [DATE]1355325963[/DATE] at [TIME]1355325963[/TIME] ---------------
Now the issue is:
Whether or not field7 is edited or not. User can not save profile changes as it gets stuck at loading state.
My inferences form this:
-> So it looks like the code is being executed for all the fields whereas it should execute only when field 7 is saved.
-> The wait for save never ends, I dont see an error or save.
but when I refersh the page the new value is saved and shown for field7.