Skip Navigation

[Resolved] Prepopulate Form fields with known values like user data or others

This thread is resolved. Here is a description of the problem and solution.

Problem:
How could we prefill certain User Form Inputs wit data for example from the current logged in user?

Solution:
You could use ShortCodes, to display the current users' name or email, or use custom ShortCodes for it (this will be necessary if Toolset ShortCodes show to have too many attributes and break the surrounding code in Forms).
The ShortCode (or any other pre-fill data) would be inserted in the Forms Drag And Drop Blocks "value" attribute - if there is none, it means the input cannot take a default value.

This support ticket is created 5 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 4 replies, has 2 voices.

Last updated by leilaG 5 years, 5 months ago.

Assisted by: Beda.

Author
Posts
#1296527

Do you have any instructions or steps on how to auto fill a users Name and email into Form fields (Add them as a default value with read only.

#1296657
Bildschirmfoto 2019-07-20 um 14.37.34.png
Bildschirmfoto 2019-07-20 um 14.36.11.png

You mean, so when a user registers to your site, he/she cannot set an own User Name and Email?
That is not really helpful, as the users will then never be able to receive any Email for example with a password, or reset instructions.

However you could set the User Name to be generated, that's a feature in Toolset Form.
For this, you'd need to check the "Auto-generate Username" checkbox when editing the user form, as seen in the screenshot

If you also want to set a value for the Email you can simply hide that field with for example CSS (display none), and preset a value using the Toolset Forms editor, which allows you to set a value for the email field.
But as said, you will have issues with this, also because WordPress simply won't allow many users with the same email.
I'd not suggest this on a user form.

#1297441

Apologies, I meant for any post form, where a user already has a user account.

To auto fill there Name and email address.

#1298335

Well, in that case, there are no User Name and User Email Fields - as those are Post Forms and simply do not feature such fields.
However, if you refer to Post Fields, like email or a single line, then you can prefill them with the exact same method as described above.
It's the same for user fields or post fields, if you open the single field in the DnD Editor and check what options you can set, you will see you can add default values.

You could use Toolset ShortCodes in there, to display the current users' name or email, or use custom ShortCodes for it too (this will be necessary if Toolset ShortCodes show to have too many attributes and break the surrounding code in Forms).

Can I help you any further with this?

#1298581

Thank you, that worked, just what we wanted.