latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Custom fields on Registration pages?

Home Forums Community Forum Unofficial Extensions/Hacks Custom fields on Registration pages?

This topic contains 6 replies, has 2 voices. Last updated by  Danny Kim 3 years, 5 months ago.

Topic Author Topic
Posted: Wednesday Jul 31st, 2013 at 6:39 pm #54539
Danny Kim
Username: dannyk1m

i get s2member says
“Regarding registration… Custom Fields do NOT appear during repeat registration and/or checkout attempts (e.g. they do NOT appear for any user that is currently logged into the site). Please make sure that you test registration and/or checkout forms while NOT logged in (e.g. please test as a first-time customer). Existing users/members/customers may update Custom Fields by editing their Profile.”

..but is it possible to add custom fields to the registration forms for renewing members?
if not all custom fields, at least one?

List Of Topic Replies

Viewing 6 replies - 1 through 6 (of 6 total)
Author Replies
Author Replies
Posted: Thursday Aug 1st, 2013 at 12:32 pm #54608
Moderator

..but is it possible to add custom fields to the registration forms for renewing members?
if not all custom fields, at least one?

No, but what you can do is redirect the customer immediately after renewal to a page that asks for any additional information you’d like to collect (e.g. ask them to update their profile now).

Please see: Dashboard -› s2Member® -› PayPal® Pro Forms -› Custom Return URLs Upon Success

I would create a page and put the [s2Member-Profile /] shortcode in it; and then redirect the customer to that page after checkout/renewal; asking them to update their profile.

Posted: Tuesday Aug 6th, 2013 at 2:01 pm #55301
Danny Kim
Username: dannyk1m

Though this should be fine…my client wants an input field (radio button option) on the checkout page.
I have created a custom field and created the html for the input. (custom field being ‘teacher-search’)
In the ‘paypal-checkout-form.php’ i added..

<?php if (is_page('teacher-registration')) { ?>
<div id="s2member-pro-paypal-registration-form-teacher-search-div" class="s2member-pro-paypal-form-div s2member-pro-paypal-registration-form-div s2member-pro-paypal-form-teacher-search-div s2member-pro-paypal-registration-form-teacher-search-div">
	<label for="s2member-pro-paypal-registration-teacher-search" id="s2member-pro-paypal-registration-form-teacher-search-label" class="s2member-pro-paypal-form-teacher-search-label s2member-pro-paypal-registration-form-teacher-search-label">
		<span>Public Teacher Search *</span><br />
        <span style="font-weight:normal;font-style:italic;">Be sure to select if you want your information 'Public' or 'Private' from the Teacher Search page.</span><br />
		<input type="radio" value="public" name="s2member_pro_paypal_registration[custom_fields][teacher_search]" id="s2member-pro-paypal-registration-custom-reg-field-teacher-search" aria-required="true" tabindex="100" class="s2member-pro-paypal-custom-reg-field-teacher-search s2member-pro-paypal-registration-custom-reg-field-teacher-search" /> Public<span style="font-weight:normal;">; If you would like to be included in the public teacher search.</span><br />
		<input type="radio" value="private" name="s2member_pro_paypal_registration[custom_fields][teacher_search]" id="s2member-pro-paypal-registration-custom-reg-field-teacher-search" aria-required="true" tabindex="101" class="s2member-pro-paypal-custom-reg-field-teacher-search s2member-pro-paypal-registration-custom-reg-field-teacher-search" /> Private<span style="font-weight:normal;">; If you do NOT want to be included in the public teacher search.</span>
	</label>
</div>
<?php } ?>

Now, how do I connect this to the database so the users ‘radio’ selection gets saved?

Posted: Tuesday Aug 6th, 2013 at 2:30 pm #55308
Moderator

Thanks for the follow-up :-)

The code to implement this custom modification would need to come from you, and it can go right into that same file (e.g. PHP tags are allowed in this file paypal-checkout-form.php when/if you need them).

The best I can do is provide you w/ a general outline below.

Getting a User’s array of custom fields.

$user_id = get_current_user_id();
$custom_fields = get_user_option('s2member_custom_fields', $user_id);

Addiing a new custom field to this array.

$custom_fields['unique_field_id'] = 'value';
// Ex: $custom_fields['teacher_search'] = esc_html($_POST['s2member_pro_paypal_registration']['custom_fields']['teacher_search']);

Updating custom fields after array modification.

update_user_option($user_id, 's2member_custom_fields', $custom_fields);

Putting it all together; it might look something like this.

$user_id = get_current_user_id();
$custom_fields = get_user_option('s2member_custom_fields', $user_id);
$custom_fields['teacher_search'] = esc_html($_POST['s2member_pro_paypal_registration']['custom_fields']['teacher_search']);
update_user_option($user_id, 's2member_custom_fields', $custom_fields);

See also: Knowledge Base » Hacking s2Member® Via Hooks/Filters
See also: s2Member® » Codex (Source Code Docs)

Posted: Tuesday Aug 6th, 2013 at 2:47 pm #55311
Danny Kim
Username: dannyk1m

what else do i need to add/change?
Didn’t work like this..

<?php
$user_id = get_current_user_id();
$custom_fields = get_user_option('s2member_custom_fields', $user_id);
$custom_fields['teacher_search'] = esc_html($_POST['s2member_pro_paypal_registration']['custom_fields']['teacher_search']);
update_user_option($user_id, 's2member_custom_fields', $custom_fields);

if (is_page('teacher-registration' || 'supporting-member-registration')) { ?>
<div id="s2member-pro-paypal-checkout-form-teacher-search-div" class="s2member-pro-paypal-form-div s2member-pro-paypal-checkout-form-div s2member-pro-paypal-form-teacher-search-div s2member-pro-paypal-checkout-form-teacher-search-div">
	<label for="s2member-pro-paypal-checkout-teacher-search" id="s2member-pro-paypal-checkout-form-teacher-search-label" class="s2member-pro-paypal-form-teacher-search-label s2member-pro-paypal-checkout-form-teacher-search-label">
		<span>Public Teacher Search *</span><br />
        <span style="font-weight:normal;font-style:italic;">Be sure to select if you want your information 'Public' or 'Private' from the Teacher Search page.</span><br />
		<input type="radio" value="public" name="s2member_pro_paypal_checkout[custom_fields][teacher_search]" id="s2member-pro-paypal-checkout-custom-reg-field-teacher-search" aria-required="true" tabindex="100" class="s2member-pro-paypal-custom-reg-field-teacher-search s2member-pro-paypal-checkout-custom-reg-field-teacher-search" /> Public<span style="font-weight:normal;">; If you would like to be included in the public teacher search.</span><br />
		<input type="radio" value="private" name="s2member_pro_paypal_checkout[custom_fields][teacher_search]" id="s2member-pro-paypal-checkout-custom-reg-field-teacher-search" aria-required="true" tabindex="101" class="s2member-pro-paypal-custom-reg-field-teacher-search s2member-pro-paypal-checkout-custom-reg-field-teacher-search" /> Private<span style="font-weight:normal;">; If you do NOT want to be included in the public teacher search.</span>
	</label>
</div>
<?php } ?>

EDIT
From the “if(is_page…” and down, it works for new user registers. adds the data correctly(without the additional php).

Posted: Tuesday Aug 6th, 2013 at 3:17 pm #55312
Moderator
That’s as far as I can go with custom code Danny, I’m sorry.
For clarification on this, please see: s2Member® » Support Policy » Within Scope

@Danny Kim I noticed that you’re running s2Member® Pro Forms. Do you have more than one account here at s2Member.com? The account you’ve written in on is listed as a Free Subscriber and not as a paying customer that owns a copy of s2Member® Pro. If you have a paid account, it is best to post under that account please.

Posted: Tuesday Aug 6th, 2013 at 3:18 pm #55313
Danny Kim
Username: dannyk1m

The Pro account is under my clients name that I do not have access to..

Viewing 6 replies - 1 through 6 (of 6 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.