Save user with save data in #_user_profiles table

Fredolino 14 Mar, 2019
Hi,

I wanted to register a new user (as in the demo with Save User)
but at the same time data should also be entered in the #_user_profiles table.

I did some experiments but it did not work. I always get this error: "1062 Duplicate entry '0-' for key 'idx_user_id_profile_key'"

Now it is in the setup that "Save User" and then "Save Data" is.
So that all user data are entered into the database at the same time, do I have to use "Save Data" in "success" of "Save User"?

I have this information:

Save User -> Black Label: joomla_user3

Save Data:
Model name: Data
Data provider: {data:}

Data override on insert:
created: {date: Y-m-e H: i: s}
{Var:} joomla_user3.id
institution: {data: jform_com_fields_firma}
strae_hausnr: {data: jform_profile_address1}
plz: {data: jform_profile_city}
wohnort: {data: jform_profile_postal_code}

Data override on Update: modified: {date: Y-m-e H: i: s}

Write action: Auto detect


Many Thanx
F.
healyhatman 14 Mar, 2019
This is what you had
{Var:} joomla_user3.id
That's a very wrong entry.


This is what you need

id:{var:joomla_user3.id}
Much better.
Fredolino 15 Mar, 2019
Hi,
In the table "#_users" the correct data about "Save User" will be entered in the database.
The profile data of the user about "Save Data" in the table "_user_profiles" will not be registered. It must look like the screen.

The error message in the frontend is only "0".
My lines in "Save Data" are wrong. The "Data override on insert" states:
{User_id: id}
{Profile.address1: strae_hausnr}

"stra_hausnr" is the ID and name of the input field of the CF6 registration form.
What do I have to change?
Save user with save data in #_user_profiles table image 1
Many thanks for your help.
F.
healyhatman 15 Mar, 2019
Did you do what I said? Screenshot proof please.
Fredolino 15 Mar, 2019
from debugger:



Array
(
    [chronoform] => registration
    [event] => submit
    [name] => Karl Marx
    [username] => Pleppo
    [email] => info@...    
[confirm_email] => info---    
[password] => xx    
[password9] => xx    
[institution] => insti
    [strae_hausnr] => strrrrrrrrrr
    [plz] => 11111
    [wohnort] => wohn
    [button10] => 
    [8cd96a265a46e007f7cfe1f554be7f0b] => 6055a6f4ffb12af0a20c72ead6d5b6c2
    [4e5ecaa84cfeae5bd080b3ed74a4d811] => 30b83b7f48cb4a22a17c24a2a74e4888
    [Itemid] => 273
    [option] => com_content
    [view] => article
    [id] => 26
    [registration] => 
)
Array
(
    [validate_fields2] => Array
        (
            [log] => Automatic validation enabled.
            [var] => 1
        )

)

Fredolino 15 Mar, 2019
Hi,
I think this article describes something of my problem:
https://www.chronoengine.com/forums/posts/t103880/save-user-id-immediately-after-creating-one
But in the "Save User" I have the action "Save Data" in the success.

As a data provider: {data:}

Data override on insert:
{Var: joomla_user3.user_id}
{Data: plz}
{Data: wohnort}

Write action: Insert

Database table: #_user_profiles

{var: joomla_user3.user_id} is the registry action (Save User) that works. The data is stored in the table "#_users".
id is the ID of the #_users table and user_id is the ID of the #_user_profiles table.

In the table "#_user_profiles", however, the city, postal code and address1 should be stored simultaneously with the registration.
But the data is entered in suddenly newly created columns. The data for the table "#_users" are suddenly in there ....

The table contents in the green frame were made with the Reg form of Joomla and are correct.
The table contents in the red frame were made with "Save Data" in the success of "Save User".
I can not find the mistake ….

Save user with save data in #_user_profiles table image 3
healyhatman 15 Mar, 2019
You need to put the name of the database field in first and then the source of the data you're putting into the field.
dbfield:{data:formfield}
dbfield:{var:actiondatavariable}
Just like I told you the first time and like the instructions and the field itself says
healyhatman 15 Mar, 2019
Also take out the {data:} from the data source that's telling your save data action to use all of the fields from your form.
Fredolino 15 Mar, 2019
nothing is simply stored in the table "user_profiles" ...
This is now in "Data override on insert":
{Var:} joomla_user3.id
var {profile.address1: strae_haus}



Save user with save data in #_user_profiles table image 4
healyhatman 15 Mar, 2019
I gave you the exact syntax to use and even told you the exact thing to use for the id as an example. If you're not going to do it I'm sorry but I don't know how else to help you.
healyhatman 15 Mar, 2019
But I'll try one more time. Your override on insert needs to look like this.
databasefieldname:source
So if your database has a field called alpha and you want to save the number 1 to it all the time that would be
alpha:1
If your table has a field called beta and your form has a field called name the user enters data into then you would put
beta:{data:name}
If your table has a field called gamma and your submit event has a Joomla save action called joomla_user5 and you want to save the Joomla user id it generates it would be
gamma:{var:joomla_user5.id}


Your "data source" field needs to be empty, otherwise it will look for form fields in your database that match the names of your form data in {data:} and try to put them in the database too. You are also going to want to turn OFF the Auto Save Fields and Auto Manage checkboxes.
Fredolino 16 Mar, 2019
Hi,

Your last post was very important to me. I had to For example, disable "Auto save fields".

user_id: {var: joomla_user3.id}
profile_key: profile.postal_code
profile_value: {data: plz}
ordering: 6

This data gives the green database entry. I do not know yet how to insert the "". Respectively, they are always in front of Joomla.

But I can not create a 2nd record, etc., to the same user_id, e.g.

profile_key: profile.city
profile_value: {data: wohnort}
ordering: 3

profile_key: profile.address1
profile_value: {data: strae_haus}
ordering: 1


Save user with save data in #_user_profiles table image 5
healyhatman 16 Mar, 2019
Answer
For multiple entries you need multiple save data actions
This topic is locked and no more replies can be posted.