Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/13/2016 03:09:52 AM (8 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/bp-xprofile-screens.php

    r10825 r11295  
    8686        $is_required      = array();
    8787
    88         // Loop through the posted fields formatting any datebox values
    89         // then validate the field.
     88        // Loop through the posted fields formatting any datebox values then validate the field.
    9089        foreach ( (array) $posted_field_ids as $field_id ) {
    91             if ( !isset( $_POST['field_' . $field_id] ) ) {
    92 
    93                 if ( !empty( $_POST['field_' . $field_id . '_day'] ) && !empty( $_POST['field_' . $field_id . '_month'] ) && !empty( $_POST['field_' . $field_id . '_year'] ) ) {
    94                     // Concatenate the values.
    95                     $date_value =   $_POST['field_' . $field_id . '_day'] . ' ' . $_POST['field_' . $field_id . '_month'] . ' ' . $_POST['field_' . $field_id . '_year'];
    96 
    97                     // Turn the concatenated value into a timestamp.
    98                     $_POST['field_' . $field_id] = date( 'Y-m-d H:i:s', strtotime( $date_value ) );
    99                 }
    100 
    101             }
     90            bp_xprofile_maybe_format_datebox_post_data( $field_id );
    10291
    10392            $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.