Forums

Form submits some data of currently logged in user

yannickv2 08 Apr, 2014
Hi,

I administer a Joomla website for an organisation that has membership subscriptions. Some columns have been added to the #_users table to hold data for each member.

A chronoforms form is used to create new members. The "Joomla User Registration" option in the onSubmit event is used to create the user and to save the additional fields to the database.

This all works fine when a new member creates an account. However, there is some issue when the member administrator is logged in herself and wants to create an account using the form. Most of the fields from the #_users table are present in the form, but the #_users table holds has some additional field that are not present in the form but that are used later on in the separate member administration system. When submitting the form, the values of all fields from the form are saved correctly in the database. But for the database columns not present in the form, the value of the currently logged in user is saved... which obviously doesn't make sense.

It seems that all values from a record in the #_users table are loaded after login, and that they are saved together with the form data as they hold the same name.

To avoid this issue, I was thinking to include a hidden field in the form (with empty value) for each database column that is not present in the form, but maybe there is a more elegant solution?
GreyHead 09 Apr, 2014
Hi yannickv2,

Generally it's a really bad idea to add columns to the core user tables - partly for this reason. ChronoForms uses the Joomla! DB code to update the table. I can't see why the current user data would be saved unless the Joomla! files are hacked to do this.

The best solution is probably either to work out where the current user info is coming from and block it; or to custom code the db save to avoid including the extra columns.

Bob

Bob
Max_admin 09 Apr, 2014
One more note here, how does the admin create/update users ? using the Joomla registration action ? if yes then that's wrong, please try to use the "Create/update user" action under the "Joomla" section in the wizard, its designed to allow creating/updating users by other users or admins.

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
yannickv2 16 Apr, 2014


Generally it's a really bad idea to add columns to the core user tables - partly for this reason.


I realize that, but the reason is that in the old (non-Joomla) website, there was already a backend administration system to administer the memberships. By making extra columns in the Joomla #_users table, only slight modification to the backend administration system was needed, instead of having to rewrite large part of this. I might still do this in the future anyway, but until now the modified #_users table didn't cause any issues apart from the one reported here.


The best solution is probably either to work out where the current user info is coming from and block it; or to custom code the db save to avoid including the extra columns.


Ok, I'll try to find out where exactly this user info is coming from.
yannickv2 16 Apr, 2014

One more note here, how does the admin create/update users ? using the Joomla registration action ? if yes then that's wrong, please try to use the "Create/update user" action under the "Joomla" section in the wizard, its designed to allow creating/updating users by other users or admins.


It uses the "Joomla user registration" action. I will try the "Joomla user create/update" and see whether that solves the problem. But can you tell me (or point me to some documentation) what exactly the difference is between both events?
Max_admin 16 Apr, 2014
There is no docs for this action but you can search the FAQs and forums, the help tab in the action itself and the hints below each field should be enough in most cases, and for this one its really straight forward, map the fields names and change the other settings to whatever you need.

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
yannickv2 17 Apr, 2014
Indeed the setup for these actions is straight-forward, I was mainly asking what the fundamental difference is between both actions? User registration and user creation... sounds very similar to me.

I tried the user creation event instead of the user registration event, but in that case only the name, username, email and password fields are saved to the database, but not the other fields that are present in the form.
So I switched back to the user registration event (which saves all fields present in the form to the database) and found a pretty easy solution for my problem: include a "Joomla logout" event.

I realize this whole setup is not ideal, but until I find the time to properly re-write the backend system, I'll need to stick with it.
This topic is locked and no more replies can be posted.