• A new version of Full Calendar is now available.

    See the details here

Solved Usergroup element not updating database on create

J! 5.1.2
F 4.2
PHP 8.2.21

I've got a Fabrik members form which uses the juser form plugin to create/update a Joomla user. The elements are all standard, including a usergroup element. Everything works correctly, HOWEVER the members usergroup database column (Fabrik, not Joomla) is empty when a record is first created. The Joomla usergroup is correctly assigned and if I edit the member in Fabrik, the record shows the correct usergroup even though nothing is showing in the database! If I edit and re-save the record in Fabrik, the database is correctly updated. And if I add another usergroup in Fabrik, the database is correctly updated.

As far as I can see, the usergroup element is set up correctly: Access is set to Public for all options, Save to database = Yes; and in Options, User element = ID and Default to current user's group = No.

I'm not sure whether this is a problem but it doesn't seem to be working as expected?

(This might not be a new issue. I've just checked an older site using J!5.0.3 and F4.0 and that database has some gaps in the usergroup column too.)
 
Last edited:
Did you select any group in the usergroup element?

I assume this behaviour was always the case.
The jUser plugin creates a user with its default (set in Options) if the usergroup element is empty.
But this group is only reloaded on edit (if the default sync on edit is set).

I assume it would make sense if the juser plugin would update the usergroup element in case of sync on edit. But not sure if this will have some backward compat impact...
 
Thanks @troester

Did you select any group in the usergroup element?
No, not on the front end. I don't want the usergroup to be visible. I want all access levels to be automatically set.

The jUser plugin creates a user with its default (set in Options) if the usergroup element is empty.
But this group is only reloaded on edit (if the default sync on edit is set).
Yes, I set the default usergroup in the jUser plugin as Registered and sync on edit as Yes.

I'm still not sure it has any detrimental impact, but I'll keep checking. I suppose I could add a form php plugin with some code to manually update the database column on New?
 
Maybe you can have a look in juser itself.
It's adding the created userid back to Fabrik, so I think this would be also the place to add back the usergroups.
Form php is certainly possible, too.
 
Everything works correctly, HOWEVER the members usergroup database column (Fabrik, not Joomla) is empty when a record is first created. The Joomla usergroup is correctly assigned and if I edit the member in Fabrik, the record shows the correct usergroup even though nothing is showing in the database! If I edit and re-save the record in Fabrik, the database is correctly updated. And if I add another usergroup in Fabrik, the database is correctly updated.
Using juser I also found the same thing, when adding records the user group field is not updated, even though it is configured correctly.

I went with the form php and it works fine
Could you share how you do it with PHP in the form? I thought about doing the same thing but I didn't have time to focus on this
Thank you
 
Certainly. It's very simple as my setup will always set the usergroup to access level Registered (2). In my code below, "am_members" is my Fabrik members table. Hope this helps!

Code:
$mydb = \Joomla\CMS\Factory::getContainer()->get('DatabaseDriver');
$my_user_id = '{am_members___id}';
$mydb->setQuery("UPDATE am_members SET user_group = '2' WHERE id = ".$mydb->Quote($my_user_id));
$mydb->execute();
 

Members online

No members online now.
Back
Top