Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/13/2016 03:09:52 AM (9 years ago)
Author:
boonebgorges
Message:

XProfile: Abstract date-parsing logic during save routines into standalone function.

This ensures that validation works the same way in all contexts where
date fields can be saved.

Props lakrisgubben.
Fixes #4187.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-xprofile/classes/class-bp-xprofile-user-admin.php

    r11246 r11295  
    228228            // Loop through the posted fields formatting any datebox values then validate the field.
    229229            foreach ( (array) $posted_field_ids as $field_id ) {
    230                 if ( ! isset( $_POST['field_' . $field_id ] ) ) {
    231                     if ( ! empty( $_POST['field_' . $field_id . '_day'] ) && ! empty( $_POST['field_' . $field_id . '_month'] ) && ! empty( $_POST['field_' . $field_id . '_year'] ) ) {
    232 
    233                         // Concatenate the values.
    234                         $date_value =   $_POST['field_' . $field_id . '_day'] . ' ' . $_POST['field_' . $field_id . '_month'] . ' ' . $_POST['field_' . $field_id . '_year'];
    235 
    236                         // Turn the concatenated value into a timestamp.
    237                         $_POST['field_' . $field_id] = date( 'Y-m-d H:i:s', strtotime( $date_value ) );
    238                     }
    239                 }
     230                bp_xprofile_maybe_format_datebox_post_data( $field_id );
    240231
    241232                $is_required[ $field_id ] = xprofile_check_is_required_field( $field_id ) && ! bp_current_user_can( 'bp_moderate' );
Note: See TracChangeset for help on using the changeset viewer.