Same user ID between 2 forms with user registration

By: Alexa Reigt | Asked: 04/10/2023
ForumsCategory: How-toSame user ID between 2 forms with user registration
Alexa ReigtAlexa Reigt asked 2 years ago
Hello all !  I write you because I'm stuck !  I can't have the same user ID in CSV attachment (for admin) between a form of user registration and a specific form when the person is connected. That's the same for the two different type of registrations I configure (2 differents roles). I use Formidable Forms + Ultimate member plugin (to access private page with second form when connected).  Sometimes I've no user ID, or user ID always with 0 in CSV attachment for the user registration.  But when the person is connected, that's fine, I've the same user in the specific form even if the person fills the form several times.  See in attachment the settings I configure. Did I miss something ?    Thanks a lot per advance for your help !   Alexa    
Attachments
Victor Font replied 2 years ago

I don’t understand the question. What’s the CSV for? Please describe your workflow. What happens when a visitor visits your site? Why do you have 2 registration forms?

Alexa ReigtAlexa Reigt replied 2 years ago

Hello !

Thanks a lot for your questions.

I need the csv attachment each time somebody fills a form.
I've 2 registration forms for 2 different roles who they will have access at their own pages :
- role 1 with : 1 registration form, 1 private page and with 1 form for this role inside the page
- role 2 with : 1 registration form, 1 private page and with 1 form for this role inside the page.

If the role 1 wants to register to access at this private page and the form inside the private page, he has to
- registers on the registration form
- wait for the approved statut of the admin
- connect with a simple login form
- access to his private page
- and fill the form inside the private page.

For these 2 forms (registration form + form inside the private page), I need each time a CSV in attachment. I configure that in the admin email when someone filled the forms. When someone fills the forms, the admin receives the entry as a new email with CSV in attachment.

The thing I need : the same user ID in the registration form and in the form inside the private page. For now, I've always
- user id 0 or nothing : for registration form
and
- user id works perfectly with the form in the private page. It's always "ID user = 34" for example, because the person is connected I supposed.
I would like to have the ID user as 34 when the person fill the registration form too. Not just when he's connected.

I did a screenshot of the configuration I use in the attachment in my previous message. Did I miss something ?

Thanks a lot for your precious help !

Alexa

Victor Font replied 2 years ago

I still don't understand why you need two registration forms just to add a user role or the CSV. It seems like an over engineered process.

Alexa ReigtAlexa Reigt replied 2 years ago

I need 2 registration forms because I've 2 differents types of roles : one for families, one for referents.
- the registration form n°1 is to ask some particular questions to the families. And when they fill the form, they will have the role of "family" given. And with that, they will have access to a private page and another form only for the role "family"
- same for referents.

Is it more clear ?

Thanks a lot for your answer !

3 Answers
Victor Font answered 2 years ago
You don't need two registration forms. In fact, it's a bad practice to have more than one registration form. Why? Because a firm principle of good data management is that every field should be a single source of truth or origin. Formidable integrates well with the WordPress User API. Ultimately, it's WordPress, not Formidable that controls user IDs. Formidable simply follows the WordPress API rules. You're trying to force an approach that bends those rules, which is why it's not working. If you only have two user roles, all you have to do is pass a parameter so your single registration form knows how to process the entry. You get the value of the parameter with the get param shortcode and store it in a hidden field. This only works if the roles are mutually exclusive. If any user can have both roles, the design needs to be different and more complex.
Victor Font replied 2 years ago

If you need to consult with an experienced Formidable Developer, please visit https://formidable-masterminds.com/developers-directory/

Alexa ReigtAlexa Reigt replied 2 years ago

Hello Victor,

Thank you for your answer.

I made progress on my projects.

Actually, I really need 2 registration forms. For the simple and good reason that I do not ask for the same information on entry for the two roles. And that I need the CSV file generated after validation of each new entry to use this CSV in another professional software.

I have now successfully generated the user ID as a "login name" when registration. It is therefore the login name that is displayed as user ID in the CSV file sent as an attachment.
The only problem I have is that this user ID takes the form of the user number of the "Accounts" section in the WordPress dashboard, and this, when a new registered/validated person fills out the 2nd form which is intended for him.
I summarize :
- once the registration form is completed: I have the user ID with the login name in CSV
- once the second form is completed (the one present in a private space after a connection): I have the user ID of "Accounts" which can be 36 for example, in CSV. And every time that person logs in and fills out that form, it's still number 36. Which is a great thing !!

What I would like: I would like the user ID of the 2 forms to be the same.
I know I can do this with PHP. But do you have a lead? Because I'm not an expert with PHP...

I followed this link (https://formidableforms.com/knowledgebase/frm_csv_columns/#kb-rename-name-fields-on-export) to change a lot of good things !

I have already been able to do a lot of things like:
- change the name of the column headers in the CSV received with each new entry
- change the name of the CSV file with each new entry
- ...

Thank you in advance for your feedback,

Good day to you

Victor Font replied 2 years ago

You have two experienced developers saying you are adapting a wrong approach by using 2 registration forms. You can have conditional content on any form. By passing a parameter, you can show/hide conditional content any way you'd like.

Walter JonesWalter Jones answered 2 years ago
It’s good that you have made progress, however the reason you are still having problems is because you’re doing something that Wordpress never intended for you to do with users.  

The path Victor was trying to lead you down is the right one.  Don’t get a registration form confused with a regular form. You can have 1 registration form to get users registered to your website.  If both user roles have different questions to ask, then create a regular form specific to each user role and collect the data after they register for your site.  So that way, your user has 1 ID in Wordpress, and you can direct them to any forms you want by passing parameters.  

You’re tryin to make lemonade out of a lemon that’s always been squeezed.  

Check out : https://formidableforms.com/knowledgebase/using-dynamic-default-values-in-fields/   https://formidableforms.com/knowledgebase/frm_after_update_entry/#kb-change-a-users-role
Alexa ReigtAlexa Reigt answered 2 years ago
Victor Font and Walter Jones,  Thanks a lot for you answer and time !  I have to see that better than I started...  Have a good day !  

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right