Skip to:
Content

BuddyPress.org

Changeset 1042


Ignore:
Timestamp:
02/09/2009 09:34:41 PM (17 years ago)
Author:
apeatling
Message:

Added xprofile $fields array checking.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-xprofile/bp-xprofile-signup.php

    r1025 r1042  
    102102    // Validate all sign up fields
    103103    $fields = BP_XProfile_Field::get_signup_fields();
    104     foreach ( $fields as $field ) {
    105        
    106         $value = $_POST['field_' . $field->id];
    107        
    108         // Need to check if the previous field had
    109         // the same ID, as to not validate individual
    110         // day/month/year dropdowns individually.
    111         if ( $prev_field_id != $field->id ) {
    112             $field = new BP_XProfile_Field($field->id);
    113            
    114             if ( 'datebox' == $field->type ) {
    115                 if ( $_POST['field_' . $field->id . '_day'] != "" && $_POST['field_' . $field->id . '_month'] != "" && $_POST['field_' . $field->id . '_year'] != "") {
    116                     $value = strtotime( $_POST['field_' . $field->id . '_day'] . " " .
    117                                         $_POST['field_' . $field->id . '_month'] . " " .
    118                                         $_POST['field_' . $field->id . '_year']);                               
     104   
     105    if ( $fields ) {
     106        foreach ( $fields as $field ) {
     107       
     108            $value = $_POST['field_' . $field->id];
     109       
     110            // Need to check if the previous field had
     111            // the same ID, as to not validate individual
     112            // day/month/year dropdowns individually.
     113            if ( $prev_field_id != $field->id ) {
     114                $field = new BP_XProfile_Field($field->id);
     115           
     116                if ( 'datebox' == $field->type ) {
     117                    if ( $_POST['field_' . $field->id . '_day'] != "" && $_POST['field_' . $field->id . '_month'] != "" && $_POST['field_' . $field->id . '_year'] != "") {
     118                        $value = strtotime( $_POST['field_' . $field->id . '_day'] . " " .
     119                                            $_POST['field_' . $field->id . '_month'] . " " .
     120                                            $_POST['field_' . $field->id . '_year']);                               
     121                    }
    119122                }
    120             }
    121            
    122             if ( is_array($value) ) {
    123                 $value = serialize( $value );
    124             }
    125            
    126             $bp_xprofile_callback[$counter] = array(
    127                 "field_id" => $field->id,
    128                 "type" => $field->type,
    129                 "value" => $value
    130             );
    131            
    132             if ( $field->is_required && empty( $value ) ) {
    133                 $bp_xprofile_callback[$counter]["error_msg"] = $field->name . ' cannot be left blank.';
    134                 $has_errors = true;
    135             }
    136            
    137             $counter++;
    138         }
    139        
    140         $prev_field_id = $field->id;
    141     }
    142 
     123           
     124                if ( is_array($value) ) {
     125                    $value = serialize( $value );
     126                }
     127           
     128                $bp_xprofile_callback[$counter] = array(
     129                    "field_id" => $field->id,
     130                    "type" => $field->type,
     131                    "value" => $value
     132                );
     133           
     134                if ( $field->is_required && empty( $value ) ) {
     135                    $bp_xprofile_callback[$counter]["error_msg"] = $field->name . ' cannot be left blank.';
     136                    $has_errors = true;
     137                }
     138           
     139                $counter++;
     140            }
     141       
     142            $prev_field_id = $field->id;
     143        }
     144    }
     145   
    143146    // validate the avatar upload if there is one.
    144147    $avatar_error = false;
Note: See TracChangeset for help on using the changeset viewer.