• Joomla 5.1

    For running J!5.1 you must install Fabrik 4.1
    See also Announcements

  • Subscription and download (Fabrik 4.1 for J!4.2+ and J!5.1) are working now

    See Announcement
    Please post subscription questions and issues here

    We have resolved the issue with the J! updater and this will be fixed in the next release.

Juser problem

FaBa

Member
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.
 
oh dear I had missed this post, FaBa is right we need to cast the value to an array. I have done that and committed the change to github

FaBa thanks for taking the time to work out what the problem was and posting the solution :)

-Rob
 
Back
Top