Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2015
    Location
    USA
    Posts
    31
    Plugin Contributions
    0

    Default Require customer to be 18 years old during account creation for date of birth field?

    I'm going to start out saying I'm new at doing any coding and I'm pretty sure there is no setting for this in the admin panel but this is something that I need on my site for legal purposes so I was hoping someone could help me out.

    I need to require the system to check to make sure the date of birth is 18 years of age during account creation. I also need to have it state the reason the account wasn't created after it gets submitted with a custom message. Basically "I'm sorry but our terms and conditions state that any person using this site must be over the age of 18, come see use on DATE THEY TURN 18"

    Thanks in advance, This site rocks

  2. #2
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    3,379
    Plugin Contributions
    9

    Default Re: Require customer to be 18 years old during account creation for date of birth fie


  3. #3
    Join Date
    Apr 2015
    Location
    USA
    Posts
    31
    Plugin Contributions
    0

    Default Re: Require customer to be 18 years old during account creation for date of birth fie

    I know I commented on the other thread that I was new and put it in the wrong category. Not sure how to delete the other one. Sorry

  4. #4
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    3,379
    Plugin Contributions
    9

    Default Re: Require customer to be 18 years old during account creation for date of birth fie

    Quote Originally Posted by timb22 View Post
    I know I commented on the other thread that I was new and put it in the wrong category. Not sure how to delete the other one. Sorry
    Welcome to the ZenCart community!

    Just take some time and read through the Forum Rules, you will get a much better response to your questions from all of us when the rules are being adhered to.

    Cheers / Frank

  5. #5
    Join Date
    Apr 2015
    Location
    USA
    Posts
    31
    Plugin Contributions
    0

    Default Re: Require customer to be 18 years old during account creation for date of birth fie

    Thank you, I will do that

  6. #6
    Join Date
    Apr 2015
    Location
    USA
    Posts
    31
    Plugin Contributions
    0

    Default Re: Require customer to be 18 years old during account creation for date of birth fie

    This is possible isn't it? I would this so but I don't even know where to start on this one

  7. #7
    Join Date
    Apr 2015
    Location
    USA
    Posts
    31
    Plugin Contributions
    0

    Default Re: Require customer to be 18 years old during account creation for date of birth fie

    I actually found this but how would I change the end where it says

    define('ENTRY_DATE_OF_BIRTH_UNDERAGE','Sorry, but you must be at least 18 to register to use this site');

    to

    define('ENTRY_DATE_OF_BIRTH_UNDERAGE','I'm sorry but our terms and conditions state that any person using this site must be over the age of 18, come see us on DATE THEY TURN 18

    I want it to automatically input 18 years after the date of birth they type into the create account.




    There is no certain way to check on a visitor's age, but you can check that the date of birth that they have given you would make them at least 18 (or any other age you choose).

    To do this create an over-ride file in your template for includes/modules/create_account.php

    Find the section of code that reads
    if (ACCOUNT_DOB == 'true') {
    if (ENTRY_DOB_MIN_LENGTH > 0 or !empty($_POST['dob'])) {
    if (substr_count($dob,'/') > 2 || checkdate((int)substr(zen_date_raw($dob), 4, 2), (int)substr(zen_date_raw($dob), 6, 2), (int)substr(zen_date_raw($dob), 0, 4)) == false) {
    $error = true;
    $messageStack->add('create_account', ENTRY_DATE_OF_BIRTH_ERROR);
    }
    }
    }

    and expand it to (setting the minimum age to whatever you wish)

    if (ACCOUNT_DOB == 'true') {
    if (ENTRY_DOB_MIN_LENGTH > 0 or !empty($_POST['dob'])) {
    if (substr_count($dob,'/') > 2 || checkdate((int)substr(zen_date_raw($dob), 4, 2), (int)substr(zen_date_raw($dob), 6, 2), (int)substr(zen_date_raw($dob), 0, 4)) == false) {
    $error = true;
    $messageStack->add('create_account', ENTRY_DATE_OF_BIRTH_ERROR);
    }
    $minimum_age = 18;
    $acceptable_dob = (date('Y') - $minimum_age) . date('md');
    if (zen_date_raw($dob) > $acceptable_dob) {
    $error = true;
    $messageStack->add('create_account', ENTRY_DATE_OF_BIRTH_UNDERAGE);
    }
    }
    }

    (note for the purists: yes, the minimum age should really be an Admin switch and yes, this is taking liberties with PHP's weak typing)

    Then create an over-ride file for your includes/languages/english/create_account.php file and place the following line in there, changing the text to suit your style of feeding errors back to visitors

    define('ENTRY_DATE_OF_BIRTH_UNDERAGE','Sorry, but you must be at least 18 to register to use this site');

 

 

Similar Threads

  1. v154 Date of Birth still in Customer Account Creation
    By edbeck in forum Customization from the Admin
    Replies: 15
    Last Post: 13 Jun 2015, 01:53 PM
  2. can I remove the birth date and newsletter from account creation?
    By eclypes2008 in forum Customization from the Admin
    Replies: 2
    Last Post: 25 Nov 2011, 07:59 AM
  3. validating custom field during account creation
    By ktrovato in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 31 Jul 2009, 04:35 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR