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.

Required fields not validating

Home Forums Community Forum Required fields not validating

This topic contains 5 replies, has 3 voices. Last updated by  Cristián Lávaque 3 years, 10 months ago.

Topic Author Topic
Posted: Tuesday Mar 5th, 2013 at 3:03 pm #43802

I am building a site and adding two custom fields, one is required the other isn’t. The one that is required is for Terms and Conditions.

When someone goes to register (http://www.clubsofthevillages.com/register/) It is letting them register without completing any of the required fields (I also have first name and last name selected in s2member). I’m not even getting a javascript popup or anything when I submit the form without the custom fields.

Someone had mentioned somewhere that there was a hack to fix this but I am unable to find that either. Any help anyone could give would be appreciated.

List Of Topic Replies

Viewing 5 replies - 1 through 5 (of 5 total)
Author Replies
Author Replies
Posted: Thursday Mar 7th, 2013 at 1:35 pm #43971
Eduan
Username: Eduan
Moderator

Hello Anthony,

Does your browser have JavaScript enabled? If it doesn’t then this won’t work, since it requires JavaScript to check if the fields are checked.

Also, you added the terms and conditions following this article?:
Knowledge Base » Force Terms & Conditions agreement

– Eduan

Posted: Thursday Mar 7th, 2013 at 2:59 pm #43986

I have Javascript Enabled. All the other scripting on my site works.

On the terms I just set it up as a required checkbox with a tag around the words “Terms and Conditions” so they could be clicked on and someone could still select/deselct the checkbox.

I ended up just modifying my functions file to make the fields required when they are being processed.

It’s not ideal but it works for what I need. Maybe this will help someone else as well:

// Validate First name, Last name, and that user has checked the terms box upon registration
function myplugin_check_fields($errors, $sanitized_user_login, $user_email) {

if ( ! preg_match(‘/^[a-zA-Z\d]+$/’, $_POST[‘ws_plugin__s2member_custom_reg_field_first_name’]) )
$errors->add( ‘first_name_error’, __(‘ERROR: Please enter a valid first name.’,’mydomain’) );

if ( ! preg_match(‘/^[a-zA-Z\d]+$/’, $_POST[‘ws_plugin__s2member_custom_reg_field_last_name’]) )
$errors->add( ‘last_name_error’, __(‘ERROR: Please enter a valid last name.’,’mydomain’) );

if ($_POST[‘ws_plugin__s2member_custom_reg_field_terms’] != “1”)
$errors->add( ‘terms_error’, __(‘ERROR: You must accept the Terms and Conditions.’,’mydomain’) );

return $errors;
}

add_filter(‘registration_errors’, ‘myplugin_check_fields’, 10, 3);

Posted: Friday Mar 8th, 2013 at 4:57 am #44044

Hi Anthony.

Thanks for sharing your hack.

Regarding the form I see in your page, it doesn’t look like a pro-form. Are you using a custom one? I see in the source code a div that mentions Theme My Login in the ID.

Posted: Friday Mar 8th, 2013 at 8:17 am #44073

I added the Theme my Login after I wasn’t able to get this working the other day. It added some additional functionality I needed and I couldn’t get the validation working with s2member so I added the custom hack and the Theme my Login script.

Posted: Sunday Mar 10th, 2013 at 1:06 am #44188

Ah ok, thanks for the update. :)

Viewing 5 replies - 1 through 5 (of 5 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.