I am using ChronoForm for Joomla 1.5 and I am wondering why the select query does not include the current record in the table. I was thinking that the record is updated before any custom code is executed.I noticed that the table is updated only after all the custom codes is executed.
I am trying to update the current record using custom code as I need to add the current username (I added a new field in my table for this)in the record.
I was trying to add the current username to the current record but it was added to the previous record not the current one. I used SELECT `cf_id` FROM my_table ORDER BY `cf_id` DESC LIMIT 1.
Are there ways to solve this?
thanks!
Hi sanchai,
You can change the order of the DB Connection, Plug-ins and Extra Code After Email on the Run-Order tab.
You can change the DB Connection to Before or After Email on the DB Connection tab (usually After is the correct setting).
Note that the OnSubmit Before Emails code, and the DB Connection (if set to Before Email) will require that Send Emails is set to Yes on the Form general tab.
Bob
Thanks Greyhead!
I checked the following tooltips in the On submit events code:
1. On Submit code - before sending email:well formatted PHP code just when form is submitted but BEFORE mail is sent.
2. On Submit code - after sending email:well formatted PHP code just when form is submitted but AFTER mail is sent.
This made me realize that my codes in "after sending email:" will be executed just when form is submitted that means, no changes yet to the table is made so I can't access the recently added record.
I am wondering how the extra codes is being used. Please tell me where can I add the code "just right after the form is submitted".
Thank you so much for your help.
sanchai
Hi sanchai,
You can access the recently added record, there are probably half-a-dozen or more threads here answering that question.
Bob
Hi GreyHead!
I would like to give you a beer as my problem is solved.
I downloaded your file "ChronoForms adding the User ID to a hidden field" and it gives me the idea that cf_user_id is actually the joomla user id. I checked my jos_users table and indeed, the id corresponds to the cf_user_id in my form table.
I don't need to add the user name to my form data anymore. This is just what I wanted.
Thank you so much GreyHead! Brilliant!
san chai
HI san chai,
Great, glad to hear that you solved it :-)
Bob