Can you see whats wrong here?
It seems the If statements are not working, it is running all 4 if statements and my UseType is 1 as can be seen in debug, The usergroup being set is from the 4th if statement, if I remove the 4th if statement then the usergroup set is from the 3rd statement ....
Is there something im doing wrong? Thanks
If ( $form->data['UseType'] = 1 ) {
$group_array = array ();
foreach ( $form->data['GetData2'] as $d ) {
$group_array[$d['ID']] = $d['DancerGP'];
}
}
If ( $form->data['UseType'] = 2 ) {
$group_array = array ();
foreach ( $form->data['GetData2'] as $d ) {
$group_array[$d['ID']] = $d['ParentGP'];
}
}
If ( $form->data['UseType'] = 3 ) {
$group_array = array ();
foreach ( $form->data['GetData2'] as $d ) {
$group_array[$d['ID']] = $d['SchoolGP'];
}
}
If ( $form->data['UseType'] = 4 ) {
$group_array = array ();
foreach ( $form->data['GetData2'] as $d ) {
$group_array[$d['ID']] = $d['OrgGP'];
}
}
$group_id = $group_array[$form->data['OrgID']];
$user_id = $form->data['_PLUGINS_']['joomla_registration']['id'];
jimport( 'joomla.user.helper' );
JUserHelper::addUserToGroup($user_id, $group_id);
?>
It seems the If statements are not working, it is running all 4 if statements and my UseType is 1 as can be seen in debug, The usergroup being set is from the 4th if statement, if I remove the 4th if statement then the usergroup set is from the 3rd statement ....
Array
(
[chronoform] => PreRegister
[event] => submit
[UseType] => 1
[OrgID] => 3
[SchID] => 35
[Name] => Test Name
[Email] => dsgds@dfgd.ie
[Username] => sdsgdfg
[Password] => as
[RePassword] => as
[g-recaptcha-response] => 03AHJ_Vuu6TNrabuq4hBbGznqz2FPWgWV6XyoQyQGfS7KS7M90jRd6XDaIsTFzJIGNDQHUk3ryQ8PjdWDntEv4uLsLjAH4OKsRlUkUZZZGsSWYOWpq5jVxdwPGSnTc1XinR_QJHGZ2JMVxbmzYJyNfOZwsQd2fIuXEBW6kzCY7sCwbQ963oAvueijpWo4iLVCN27lt6CFBjT4MGCeXYzy3xdYubofwVQVNX_F-03Awd03YKySXLWY7ZjsEDIydrt2ILKDAFOLEVzTlVSJBegsrhbCWrER_7WkzXeK3kfJP-G4IrSmnijyYDbGazby4Zq3Gp3tf6QSgWaooDLxBYsL_PKzQD5rdrV2ydj0SUP_6jkspWK49bIyhoxKnwVTPEYm2P2Ldu6MUi2f3zjh5iAyHOjrZfvNyhOarhThoZ4uEnIqsIDgdp5feeOh2e_qVlLPtjtq22gBHzbS0bKrIGZWtkT-XVN4MPKFMi3gbXKku3SDhkj73bYWHY3ntwAOAPQBxHKWZot7g5UhGnmdkrlu703Aq9_gAgyu74nYNzN4uFpcmfG87H5hH6ZDu-asgPhu6d2raUciDiNHa9kIglYK2-Is3vuMtcYmregG6_Ok_DV-l6HobF53RmT6U6QOczriFPqJPGWNC5Zw-H47SLQ691LyyXB--6heur5TuWQKbydmahZhg9WCD-cm8Lpr-OFQXG2iCmFcw4Zy5DF-M6b5BG6IwbTpHVy_t9g_sBbyB4G8lCsfdFT42ry4KS_GCMLl2mi6WJOF4kn-J8HL30Ei692yTIOjPPJ2wFrDIvzXNUbJe_TzFh8jbY84
[button5] => Submit
[user_id] => 129
[Org_Name] =>
[School_Name] =>
[name] => Test Name
[username] => sdsgdfg
[email] => dsgds@dfgd.ie
[password] => as
[password2] => as
[_PLUGINS_] => Array
(
[joomla_registration] => Array
(
[*isRoot] =>
[id] => 129
[name] => Test Name
[username] => sdsgdfg
[email] => dsgds@dfgd.ie
[password] => $2y$10$DQBIRwMXd2LvIy9KZniTBOQd1K3LEKnoDQeDvIbRl4l.k1peKMVhe
[password_clear] => as
[block] =>
[sendEmail] => 0
[registerDate] => 2015-08-26 13:59:01
[lastvisitDate] =>
[activation] =>
[groups] => Array
(
[0] => 2
)
[lastResetTime] =>
[resetCount] =>
[requireReset] =>
[*_params] => Joomla\Registry\Registry Object
(
[data:protected] => stdClass Object
(
)
[separator] => .
)
[*_authGroups] => Array
(
[0] => 1
[1] => 9
)
[*_authLevels] => Array
(
[0] => 1
[1] => 1
[2] => 5
)
[*_authActions] =>
[*_errorMsg] =>
[*userHelper] => JUserWrapperHelper Object
(
)
[*_errors] => Array
(
)
[aid] => 0
[chronoform] => PreRegister
[event] => submit
[UseType] => 1
[OrgID] => 3
[SchID] => 35
[Name] => Test Name
[Email] => dsgds@dfgd.ie
[Username] => sdsgdfg
[Password] => as
[RePassword] => as
[g-recaptcha-response] => 03AHJ_Vuu6TNrabuq4hBbGznqz2FPWgWV6XyoQyQGfS7KS7M90jRd6XDaIsTFzJIGNDQHUk3ryQ8PjdWDntEv4uLsLjAH4OKsRlUkUZZZGsSWYOWpq5jVxdwPGSnTc1XinR_QJHGZ2JMVxbmzYJyNfOZwsQd2fIuXEBW6kzCY7sCwbQ963oAvueijpWo4iLVCN27lt6CFBjT4MGCeXYzy3xdYubofwVQVNX_F-03Awd03YKySXLWY7ZjsEDIydrt2ILKDAFOLEVzTlVSJBegsrhbCWrER_7WkzXeK3kfJP-G4IrSmnijyYDbGazby4Zq3Gp3tf6QSgWaooDLxBYsL_PKzQD5rdrV2ydj0SUP_6jkspWK49bIyhoxKnwVTPEYm2P2Ldu6MUi2f3zjh5iAyHOjrZfvNyhOarhThoZ4uEnIqsIDgdp5feeOh2e_qVlLPtjtq22gBHzbS0bKrIGZWtkT-XVN4MPKFMi3gbXKku3SDhkj73bYWHY3ntwAOAPQBxHKWZot7g5UhGnmdkrlu703Aq9_gAgyu74nYNzN4uFpcmfG87H5hH6ZDu-asgPhu6d2raUciDiNHa9kIglYK2-Is3vuMtcYmregG6_Ok_DV-l6HobF53RmT6U6QOczriFPqJPGWNC5Zw-H47SLQ691LyyXB--6heur5TuWQKbydmahZhg9WCD-cm8Lpr-OFQXG2iCmFcw4Zy5DF-M6b5BG6IwbTpHVy_t9g_sBbyB4G8lCsfdFT42ry4KS_GCMLl2mi6WJOF4kn-J8HL30Ei692yTIOjPPJ2wFrDIvzXNUbJe_TzFh8jbY84
[button5] => Submit
[user_id] =>
[Org_Name] =>
[School_Name] =>
[password2] => as
[usertype] => deprecated
)
)
[GetData2] => Array
(
[0] => Array
(
[ID] => 1
[DancerGP] => 28
[SchoolGP] => 30
[ParentGP] => 42
[OrgGP] => 34
)
[1] => Array
(
[ID] => 2
[DancerGP] => 45
[SchoolGP] => 46
[ParentGP] => 43
[OrgGP] => 47
)
[2] => Array
(
[ID] => 3
[DancerGP] => 29
[SchoolGP] => 32
[ParentGP] => 48
[OrgGP] => 36
)
[3] => Array
(
[ID] => 4
[DancerGP] => 39
[SchoolGP] => 51
[ParentGP] => 49
[OrgGP] => 50
)
[4] => Array
(
[ID] => 5
[DancerGP] => 52
[SchoolGP] => 55
[ParentGP] => 53
[OrgGP] => 54
)
[5] => Array
(
[ID] => 6
[DancerGP] => 56
[SchoolGP] => 59
[ParentGP] => 57
[OrgGP] => 58
)
[6] => Array
(
[ID] => 7
[DancerGP] => 60
[SchoolGP] => 63
[ParentGP] => 61
[OrgGP] => 62
)
[7] => Array
(
[ID] => 8
[DancerGP] => 67
[SchoolGP] => 64
[ParentGP] => 66
[OrgGP] => 65
)
[8] => Array
(
[ID] => 9
[DancerGP] => 27
[SchoolGP] => 31
[ParentGP] => 41
[OrgGP] => 35
)
[9] => Array
(
[ID] => 10
[DancerGP] => 40
[SchoolGP] => 69
[ParentGP] => 44
[OrgGP] => 68
)
[10] => Array
(
[ID] => 11
[DancerGP] => 70
[SchoolGP] => 73
[ParentGP] => 71
[OrgGP] => 72
)
[11] => Array
(
[ID] => 12
[DancerGP] => 74
[SchoolGP] => 77
[ParentGP] => 75
[OrgGP] => 76
)
[12] => Array
(
[ID] => 13
[DancerGP] => 78
[SchoolGP] => 81
[ParentGP] => 79
[OrgGP] => 80
)
[13] => Array
(
[ID] => 14
[DancerGP] => 82
[SchoolGP] => 85
[ParentGP] => 83
[OrgGP] => 84
)
[14] => Array
(
[ID] => 15
[DancerGP] => 86
[SchoolGP] => 89
[ParentGP] => 87
[OrgGP] => 88
)
[15] => Array
(
[ID] => 16
[DancerGP] => 90
[SchoolGP] => 93
[ParentGP] => 91
[OrgGP] => 92
)
[16] => Array
(
[ID] => 17
[DancerGP] => 94
[SchoolGP] => 97
[ParentGP] => 95
[OrgGP] => 96
)
[17] => Array
(
[ID] => 18
[DancerGP] => 98
[SchoolGP] => 101
[ParentGP] => 99
[OrgGP] => 100
)
[18] => Array
(
[ID] => 19
[DancerGP] => 102
[SchoolGP] => 105
[ParentGP] => 103
[OrgGP] => 104
)
)
[ID] => 40
)
Array
(
)
Errors
Array
(
)
Debug Info
Array
(
[38] => Array
(
[DB Read] => Array
(
[Queries] => Array
(
[0] => SELECT `GetData2`.`ID` AS `GetData2.ID`, `GetData2`.`DancerGP` AS `GetData2.DancerGP`, `GetData2`.`SchoolGP` AS `GetData2.SchoolGP`, `GetData2`.`ParentGP` AS `GetData2.ParentGP`, `GetData2`.`OrgGP` AS `GetData2.OrgGP` FROM `Mak_z_Organization` AS `GetData2`
)
)
)
[36] => Array
(
[DB Save] => Array
(
[Queries] => Array
(
[0] => INSERT INTO `Mak_z_user` (`OrgID`, `SchID`, `user_id`, `Org_Name`, `School_Name`) values ('3', '35', '129', '', '');
)
)
)
)
Is there something im doing wrong? Thanks