Changeset 11295
- Timestamp:
- 12/13/2016 03:09:52 AM (7 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-members/bp-members-screens.php
r11032 r11295 150 150 // Loop through the posted fields formatting any datebox values then validate the field. 151 151 foreach ( (array) $profile_field_ids as $field_id ) { 152 if ( !isset( $_POST['field_' . $field_id] ) ) { 153 if ( !empty( $_POST['field_' . $field_id . '_day'] ) && !empty( $_POST['field_' . $field_id . '_month'] ) && !empty( $_POST['field_' . $field_id . '_year'] ) ) 154 $_POST['field_' . $field_id] = date( 'Y-m-d H:i:s', strtotime( $_POST['field_' . $field_id . '_day'] . $_POST['field_' . $field_id . '_month'] . $_POST['field_' . $field_id . '_year'] ) ); 155 } 152 bp_xprofile_maybe_format_datebox_post_data( $field_id ); 156 153 157 154 // Create errors for required fields without values. … … 219 216 $profile_field_ids = explode( ',', $_POST['signup_profile_field_ids'] ); 220 217 221 // Loop through the posted fields formatting any datebox values then add to usermeta - @todo This logic should be shared with the same in xprofile_screen_edit_profile(). 218 /* 219 * Loop through the posted fields, formatting any 220 * datebox values, then add to usermeta. 221 */ 222 222 foreach ( (array) $profile_field_ids as $field_id ) { 223 if ( ! isset( $_POST['field_' . $field_id] ) ) { 224 225 if ( ! empty( $_POST['field_' . $field_id . '_day'] ) && ! empty( $_POST['field_' . $field_id . '_month'] ) && ! empty( $_POST['field_' . $field_id . '_year'] ) ) { 226 // Concatenate the values. 227 $date_value = $_POST['field_' . $field_id . '_day'] . ' ' . $_POST['field_' . $field_id . '_month'] . ' ' . $_POST['field_' . $field_id . '_year']; 228 229 // Turn the concatenated value into a timestamp. 230 $_POST['field_' . $field_id] = date( 'Y-m-d H:i:s', strtotime( $date_value ) ); 231 } 232 } 223 bp_xprofile_maybe_format_datebox_post_data( $field_id ); 233 224 234 225 if ( !empty( $_POST['field_' . $field_id] ) ) -
trunk/src/bp-xprofile/bp-xprofile-functions.php
r11243 r11295 1288 1288 return $field_ids; 1289 1289 } 1290 1291 /** 1292 * Formats datebox field values passed through a POST request. 1293 * 1294 * @since 2.8.0 1295 * 1296 * @param int $field_id The id of the current field being looped through. 1297 * @return void This function only changes the global $_POST that should contain 1298 * the datebox data. 1299 */ 1300 function bp_xprofile_maybe_format_datebox_post_data( $field_id ) { 1301 if ( ! isset( $_POST['field_' . $field_id] ) ) { 1302 if ( ! empty( $_POST['field_' . $field_id . '_day'] ) && ! empty( $_POST['field_' . $field_id . '_month'] ) && ! empty( $_POST['field_' . $field_id . '_year'] ) ) { 1303 // Concatenate the values. 1304 $date_value = $_POST['field_' . $field_id . '_day'] . ' ' . $_POST['field_' . $field_id . '_month'] . ' ' . $_POST['field_' . $field_id . '_year']; 1305 1306 // Check that the concatenated value can be turned into a timestamp. 1307 if ( $timestamp = strtotime( $date_value ) ) { 1308 // Add the timestamp to the global $_POST that should contain the datebox data. 1309 $_POST['field_' . $field_id] = date( 'Y-m-d H:i:s', $timestamp ); 1310 } 1311 } 1312 } 1313 } -
trunk/src/bp-xprofile/bp-xprofile-screens.php
r10825 r11295 86 86 $is_required = array(); 87 87 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. 90 89 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 ); 102 91 103 92 $is_required[ $field_id ] = xprofile_check_is_required_field( $field_id ) && ! bp_current_user_can( 'bp_moderate' ); -
trunk/src/bp-xprofile/classes/class-bp-xprofile-user-admin.php
r11246 r11295 228 228 // Loop through the posted fields formatting any datebox values then validate the field. 229 229 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 ); 240 231 241 232 $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.