A db read action shows the data of the wrong user!!!
It worked for several weeks - but suddenly db read shows he wrong user.
The user has to register and login. After that he will be redirected to the form with his data he put in during an earlier session.
I registered user A - put data in the form for userA > than I registered user B - put data in the form for userB > than I logged in again as user A but I get the data of user B.
db read conditions:
<?php
$user = \JFactory::getUser();
if ( $user->id > 0 ) {
return array( 'user_id' => $user->id );
} else {
return array( ": 'AAA' = 'ZZZ' " );
}
?>
Can anybody help me?
Hi hcohl ,
Please drag a Debugger action into the On Submit event, then submit the form. That should show you the MySQL query being created so that you can check the User id.
You also may need to clear your browser cache after logging out to make sure that the data from the first Joomla! User session is cleared.
Bob
You are right. The problem is the user id.
In my form I have a hiddenfield user_id.
I logged in two users for testing. Under joomla-users they have a different id. But in the records they got the same id (the id of the first user I logged in) in the hiddenfield user_id.
The debugger doesn't show the user_id.
I tested this with
<?php
$user = JFactory::getUser();
return array("user_id" => $user->get("id"));
?>
in the db read action.
Perhaps I have to log out before logging in the next user. Is there a posibility to automaticly log out when submitting the form?
Is there a posibility to automaticly log out when submitting the form?
Hi hcohl,
What exactly are you trying to do here? Normally users don't use more than one id so this won't be a problem. It may just be something that you are seeing in testing. Using two different browsers might solve that.
I think that there is a JUser::logout(); method that you could use if it is needed.
Bob
I builded a form for users to put in their CV.
They should close the form and reopen it later to continue editing.
For this I builded a db save and a db read action.
Now users must not begin editing the form without being logged in. For this I put a loggin-form before the CV-form.
If now a user wants to reopen his CV-form, first he must login. But if he isn't logged out before first he has to logout and than he can log in. Thats a bit complicate.
(If you want to see my form:
http://give-consulting.com/_test/index.php?option=com_content&view=article&id=7&Itemid=8&lang=de
Please go to the right bottom to register and ogin)
JUser::logout(); as custom code in the on submit action?????
Hi hcohl,
If the user is already logged in, then why should they logout or in again ?
Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Thats right. I can give access to the form only by the login form. Joomla requires this. But I found an other solution for that.
Thank you.