Ticket #4187: 4187.1.diff
File 4187.1.diff, 6.4 KB (added by , 9 years ago) |
---|
-
src/bp-members/bp-members-screens.php
149 149 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. 158 155 if ( xprofile_check_is_required_field( $field_id ) && empty( $_POST[ 'field_' . $field_id ] ) && ! bp_current_user_can( 'bp_moderate' ) ) … … 218 215 // Let's compact any profile field info into usermeta. 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 // Loop through the posted fields formatting any datebox values then add to usermeta 222 219 foreach ( (array) $profile_field_ids as $field_id ) { 223 if ( ! isset( $_POST['field_' . $field_id] ) ) {220 bp_xprofile_maybe_format_datebox_post_data( $field_id ); 224 221 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 }233 234 222 if ( !empty( $_POST['field_' . $field_id] ) ) 235 223 $usermeta['field_' . $field_id] = $_POST['field_' . $field_id]; 236 224 -
src/bp-xprofile/bp-xprofile-functions.php
1287 1287 1288 1288 return $field_ids; 1289 1289 } 1290 1291 /** 1292 * Formats any datebox 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 the datebox data. 1298 */ 1299 function bp_xprofile_maybe_format_datebox_post_data( $field_id ) { 1300 if ( ! isset( $_POST['field_' . $field_id ] ) ) { 1301 if ( ! empty( $_POST['field_' . $field_id . '_day'] ) && ! empty( $_POST['field_' . $field_id . '_month'] ) && ! empty( $_POST['field_' . $field_id . '_year'] ) ) { 1302 // Concatenate the values. 1303 $date_value = $_POST['field_' . $field_id . '_day'] . ' ' . $_POST['field_' . $field_id . '_month'] . ' ' . $_POST['field_' . $field_id . '_year']; 1304 1305 // Check that the concatenated value can be turned into a timestamp. 1306 if ( $timestamp = strtotime( $date_value ) ) { 1307 // Add the timestamp to the global $_POST that should contain the datebox data. 1308 $_POST['field_' . $field_id] = date( 'Y-m-d H:i:s', $timestamp ); 1309 } 1310 } 1311 } 1312 } -
src/bp-xprofile/bp-xprofile-screens.php
85 85 $posted_field_ids = wp_parse_id_list( $_POST['field_ids'] ); 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] ) ) {90 bp_xprofile_maybe_format_datebox_post_data( $field_id ); 92 91 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 }102 103 92 $is_required[ $field_id ] = xprofile_check_is_required_field( $field_id ) && ! bp_current_user_can( 'bp_moderate' ); 104 93 if ( $is_required[$field_id] && empty( $_POST['field_' . $field_id] ) ) { 105 94 $errors = true; -
src/bp-xprofile/classes/class-bp-xprofile-user-admin.php
227 227 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'] ) ) { 230 bp_xprofile_maybe_format_datebox_post_data( $field_id ); 232 231 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 }240 241 232 $is_required[ $field_id ] = xprofile_check_is_required_field( $field_id ) && ! bp_current_user_can( 'bp_moderate' ); 242 233 if ( $is_required[ $field_id ] && empty( $_POST['field_' . $field_id ] ) ) { 243 234 $redirect_to = add_query_arg( 'error', '2', $redirect_to );