Tips and Tricks HQ Support Portal › Forums › WP eMember › prepopulate a hidden custom field
Tagged: custom field, hidden field
- This topic has 8 replies, 3 voices, and was last updated 3 years, 3 months ago by admin.
-
AuthorPosts
-
August 4, 2021 at 8:54 am #83456kb6104Spectator
We are trying to integrate wp emember with an API for a white label service that our client can make available to their customers. Each customer registration needs to include a custom field that is prepopulated with a value that identifies that customer with our client. The value is the same for each customer.
Is it possible to add a custom field that is
a. hidden
b. prepopulated with the same value
c. is included in the registration and login formsThe API will pass the username and customer ID. This custom field needs to be the same value for each customer so that they are associated to the Client account.
August 4, 2021 at 8:53 pm #83459wzpModeratorHave you taken a look at our Form Builder Addon for eMember? It does support hidden fields.
August 5, 2021 at 1:32 pm #83468kb6104SpectatorI purchased and installed the form builder addon to see if I could get the functionality I’m looking for. I built a new registration form with an added custom field. In the form builder I added a default value to the custom field but that value is not populating the field on the registration page. Ideally, I want the field to “show in Admin only” but also add the default value to the member profile when a new member’s registration form is submitted.
Currently, I have to add the default value manually in the wordpress dashboard.
The wordpress version is 5.8. I am using WP theme Twenty Twenty-One.
August 5, 2021 at 1:39 pm #83469kb6104SpectatorAlso, the custom field is set to “Read Only” yet it can be selected and typed in.
August 5, 2021 at 4:10 pm #83472adminKeymasterI think the way to add a hidden field with a pre-set value to the form builder would be to do the following:
1) Add a normal custom text field
2) Set the value in the “Default Value” option within that field.
3) On the front-end, inspect the HTML code of the registration form so you can identify the CSS Class or ID for the field and hide it using a CSS tweak. For example, the following will hide the custom text field on my registration form#item-vfb-text-18 { display: none; }
The other alternative would be to do a custom coding job.
August 6, 2021 at 7:53 am #83482kb6104SpectatorThe issue is not with hiding the field, that is handled with the “show in Admin only”
The problem is that the default value is not populating the field. When “show in Admin only” is unchecked, The custom field shows up on the registration form but the default value is not there. When inspected, the form code shows value=””.
I purchased the Addon in order to be able to use hidden fields but it seems that with your instructions I only need CSS not a premium plugin.
August 10, 2021 at 7:41 am #83493kb6104SpectatorTo clarify, the issue is not so much with hiding the field. I think I wasn’t so clear on that until I really started working with the plugin. The real issue is that the default value has been added to a “read only” custom field in the form builder. This value is not populating the field, whether, hidden or showing in the live registration form.
August 10, 2021 at 7:42 am #83494kb6104SpectatorThis is what shows up on the live form:
August 11, 2021 at 1:28 am #83502adminKeymasterI can make the default value to show in the text field for the registration form. However, what you are trying to do is not how the read-only field is supposed to be used actually. Every member’s profile will have a value that is specific to that member. So a field’s value needs to be set from the edit profile field. An admin can set a value for a field by editing a membership profile. Then that value is what the member sees without being able to edit.
You can’t set a static value from the form builder configuration which is going to be in edit profile of the member since the edit profile form reads the value from a different place.
I will send you an email.
-
AuthorPosts
- You must be logged in to reply to this topic.