Hello everyone,
I've either found a bug in juser.php or just plain misunderstood how it's supposed to work. I have a fabrik form that uses Juser to create user accounts and it almost works. The problem is that it doesn't save usertype in the database, which prevents the user from viewing anything.
I've looked at the code and narrowed it down to the method setGroupIds(), and more specifically row 671:
$groupIds = $this->getFieldValue($params, 'juser_field_usertype', $formModel->_formData, $defaultGroup);
$this->getFieldValue returns an integer that corresponds to the default usertype, in this case 2 which stands for Registered.
This is a problem because on row 678 when JArrayHelper::toInteger($groupIds); is called, $groupIds gets converted to an empty array.
I managed to get around this by adding a cast to an array on row 671:
$groupIds = (array) $this->getFieldValue($params, 'juser_field_usertype', $formModel->_formData, $defaultGroup);
And when $groupIds is an array the rest of the code works and the usertype gets saved as it should.
Is it supposed to be like this? Because I don't know of any way to make the default value into an array from the fabrik settings.
I've either found a bug in juser.php or just plain misunderstood how it's supposed to work. I have a fabrik form that uses Juser to create user accounts and it almost works. The problem is that it doesn't save usertype in the database, which prevents the user from viewing anything.
I've looked at the code and narrowed it down to the method setGroupIds(), and more specifically row 671:
$groupIds = $this->getFieldValue($params, 'juser_field_usertype', $formModel->_formData, $defaultGroup);
$this->getFieldValue returns an integer that corresponds to the default usertype, in this case 2 which stands for Registered.
This is a problem because on row 678 when JArrayHelper::toInteger($groupIds); is called, $groupIds gets converted to an empty array.
I managed to get around this by adding a cast to an array on row 671:
$groupIds = (array) $this->getFieldValue($params, 'juser_field_usertype', $formModel->_formData, $defaultGroup);
And when $groupIds is an array the rest of the code works and the usertype gets saved as it should.
Is it supposed to be like this? Because I don't know of any way to make the default value into an array from the fabrik settings.