Hi!
I would like to know if this is possible. I would like to create a form that is visible to all users (logged in or not). After a visitor (not logged in) submits the form, he will be required to log in/register in order to save the entry.
I know I can just hide the form or page from guest users but I would like the form to be visible to all users. And I need the form submissions to be tied to a user account.
Thanks in advance!
If I understand your situation correctly, you can pass the submitted entry ID or key to the login or registration form and when the login or registration happens, you can set the userid field of that submitted entry to the current user's ID. One flaw in this is if the user leaves the website without logging in or registering, their entry will be in limbo permanently.
Thanks Rob! Just to clarify, does the above example only work if the login/registration form is built using Formidable?
The strategy will work as long as the login and registration actions provide a developer hook that will allow you to do your thing post-login and post-registration.
I'm now trying to give this a go and I can now successfully pass the entry ID or key to another page containing the login/registration form. But I can't figure out how to set the userid of the submitted entry. Could you please provide some guidance here? Thanks much!
Assuming you're in a hook belonging to a non-Formidable product, you'll have set the value via Formidable commands or direct SQL. You either update (if the user ID field has a value already) or insert the data into the frm_item_metas table. User FrmEntryMeta::update_entry_meta or FrmEntryMeta::add_entry_meta to do that. See this example - https://formidableforms.com/knowledgebase/php-examples/#kb-update-a-field-value
Please login or Register to submit your answer