Pass Date of Birth custom field

Hi,

I'm trying to pass a dob from the form on the website to cm. it currently sending all the other data but not the dob. Here is the code:

if(!empty($_POST)) {
        
        //Get form data into variables
        $name = $_POST['cm-name'];
        $email = $_POST['cm-email'];
        $dob = $_POST['cm-dob-month'] . $_POST['cm-dob-date'] . $_POST['cm-dob-year'];
        $birthdayCode = $_POST['birthdayCode'];
        $offerCode1 = $_POST['offerCode1'];
        $offerCode2 = $_POST['offerCode2'];
        $offerCode3 = $_POST['offerCode3'];
        $offerCode4 = $_POST['offerCode4'];
        
        //add form data to campaign monitor api and submit to list
        //api key is from account settings from campaign monitor
        $auth = array('api_key' => '...');
           
         //List id is found by clicking on the change name/type link when clicking in to the list
        $wrap = new CS_REST_Subscribers('...', $auth);
        
        $result = $wrap->add(array(
            'EmailAddress' => $email,
            'Name' => $name,
            'CustomFields' => array(
                array(
                    'Key' => 'dob',
                    'Value' => $dob
                ),
                array(
                    'Key' => 'birthdayCode',
                    'Value' => $birthdayCode
                ),
                array(
                    'Key' => 'offerCode1',
                    'Value' => $offerCode1
                ),
                array(
                    'Key' => 'offerCode2',
                    'Value' => $offerCode2
                ),
                array(
                    'Key' => 'offerCode3',
                    'Value' => $offerCode3
                ),
                array(
                    'Key' => 'offerCode4',
                    'Value' => $offerCode4
                )
            ),
            'Resubscribe' => true,
            "RestartSubscriptionBasedAutoresponders" => true
        ));

.............................
matthewjrallen, 1 year ago

I have fixed this problem. I put the year first and added / between the date fields on the variable.

$dob = $_POST['cm-dob-year'] . '/' . $_POST['cm-dob-date'] . '/' . $_POST['cm-dob-month'];

200,000 companies around the world can't be wrong.

From Australia to Zimbabwe, and everywhere in between, companies count on 
Campaign Monitor for email campaigns that drive real business results.

Get started for free
1-888-533-8098