Tips and Tricks HQ Support Portal › Forums › WP eMember › WP eMember General Questions › emember custom fields with gravity forms
- This topic has 9 replies, 2 voices, and was last updated 9 years, 3 months ago by admin.
-
AuthorPosts
-
July 14, 2015 at 1:38 pm #12870dannhanksMember
Hi, I am using the emembers plugin and have purchased the add on for the registration form. Within my site I want my users to be able to sumbit a form using gravity forms.
I need the first half of the form to be pre-populated with user data from registration.
This includes title, first name, last name etc..
Searching through the fourm I have found the solution to load the values into a gravity forms form with use of:
add_filter(‘gform_field_value_fname’, ‘custom_populate_fname’);
function custom_populate_fname($value){
if(wp_emember_is_member_logged_in()){
$emember_auth = Emember_Auth::getInstance();
$first_name= $emember_auth->getUserInfo(‘first_name’);
return $first_name;
}
}
…added to my functions.php file and ‘fname’ named in my gravity form as the “Parameter Name”
This has worked great up to the point that I want something a little more custom.
On the standard “Title” dropdown in registration, there is only 5: Mr, Mrs, Miss, Ms, Dr… I need to include extras such as Prof and Rev.
I tried to hack at the eMember_registration_utils.php and eMember_profile_utils.php files. This added the desired options but did not save the values. I then tried purchasing the form creation add on and added the extra dropdown options here. This is saving the values but I cant find a way to load this into the gravity form. What would I use to call the custom information with this bit:
$first_name= $emember_auth->getUserInfo(‘first_name’);
return $first_name;
Thanks for any help!
July 15, 2015 at 1:06 am #70785adminKeymasterThe form builder addon won’t work with anything but emember. The form builder is a very custom piece of addon that does ONLY what is explained on it’s landing page:
https://www.tipsandtricks-hq.com/wordpress-membership/wp-emember-form-builder-addon-extension-760
What I can do is add more title options in the core registration form like “Prof” and “Rev”. Let me know if that will work.
July 15, 2015 at 2:27 pm #70786dannhanksMemberHi, thanks yes that will work for me, the full list of items which my client was after included:
Rev
Prof
Br
Sr
… there are a few other custom fields I need here too. Will I be able to pull this information through to the gravity form if I use emember’s custom fields?
thanks..
Dann
July 20, 2015 at 8:24 am #70787dannhanksMemberhi, any updates?
July 21, 2015 at 1:10 am #70788adminKeymasterWe looked into it and I think given what you are trying to do, the form builder will be the best option.
You should be able to retrieve the fields from the form builder using the following example code. Lets say the name of the title custom field that you configured in form builder is “Title”
$emember_auth = Emember_Auth::getInstance();
$value = $emember_auth->getUserInfo("Title");August 4, 2015 at 4:27 pm #70789dannhanksMemberHi, I have tried several combinations of this and I cant get it to work.
On my form this is the code for the custom field:
<select id=”vfb-title-9″ class=”vfb-text vfb-medium valid” name=”emember_custom[title]”><option value=”Mr”>Mr</option>
<option value=”Mrs”>Mrs</option>
<option value=”Miss”>Miss</option>
<option value=”Ms”>Ms</option>
<option value=”Dr”>Dr</option>
<option value=”Prof”>Prof</option>
<option value=”Rev”>Rev</option>
<option value=”Br”>Br</option>
<option value=”Sr”>Sr</option>
</select>
… which I assume means I should be referencing: “emember_custom[title]” as the custom field name.
I have tried both:
$emember_auth = Emember_Auth::getInstance();
$value = $emember_auth->getUserInfo(“emember_custom[title]”);
and
$emember_auth = Emember_Auth::getInstance();
$value = $emember_auth->getUserInfo(“title”);
while referencing my parameter name as both “emember_custom[title]” and “title” in my gravity form.
I cant get any of it to work.
It seems I am able to get any of the pre built functions from the form builder such as phone or street address but as soon as I use a custom one, the name field appears as emember_custom[thetitle] , I guess it’s this that’s causing the issue?
I hope there is a way around this.
thanks for your help!
Dann
August 7, 2015 at 9:24 am #70790dannhanksMemberhello, can you offer any advice on the above? thanks!
August 8, 2015 at 12:52 am #70791adminKeymasterInstead of using the standard title field, can you add a standard custom dropdown box called “Title Custom” or something similar?
Then retrieve the value of that field? Does that work?
August 28, 2015 at 4:05 pm #70792dannhanksMemberHi, I cant get ANY custom fields to pre-load into the fields. I am guessing this is to do with the odd name it gives the fields when adding custom fields…
It would be easier if we tried to tackle an easier part of the form which I need to load.
So, I have added a custom text field “address line 2”
When filling in the registration form it gives me the output of:
<input type=”text” name=”emember_custom[address-line-2]” class=”vfb-text vfb-medium” id=”vfb-address-line-2-29″ value=””>
… so I add this to my functions.php file:
add_filter(‘gform_field_value_add2’, ‘custom_populate_add2’);
function custom_populate_add2($value){
if(wp_emember_is_member_logged_in()){
$emember_auth = Emember_Auth::getInstance();
$value= $emember_auth->getUserInfo(’emember_custom[address-line-2]’);
return $value;
}
}
and in my gravity forms I set the “Allow field to be populated dynamically” Parameter name to: emember_custom[address-line-2]
… it doesnt load.
If I add a pre-defined field from the form builder, I can retrieve and populate the field but as soon as its a custom one it adds the name in a weird format such as: name=”emember_custom[field-name]”
… I am guessing its having trouble with the odd format that adding a custom field seems to do when naming the field?
Any help would be great… Thanks!
August 29, 2015 at 12:41 am #70793adminKeymasterTo retrieve that custom field, use the following
if(wp_emember_is_member_logged_in()){
$emember_auth = Emember_Auth::getInstance();
$value= $emember_auth->getUserInfo('address-line-2');
} -
AuthorPosts
- You must be logged in to reply to this topic.