Skip to:
Content

BuddyPress.org

Changeset 2645


Ignore:
Timestamp:
02/10/2010 03:24:26 PM (14 years ago)
Author:
apeatling
Message:

Fixes #1865

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-xprofile.php

    r2576 r2645  
    299299        $posted_field_ids = explode( ',', $_POST['field_ids'] );
    300300
     301        $is_required = array();
     302
    301303        /* Loop through the posted fields formatting any datebox values then validate the field */
    302304        foreach ( (array)$posted_field_ids as $field_id ) {
     
    315317            }
    316318
    317             if ( xprofile_check_is_required_field( $field_id ) && empty( $_POST['field_' . $field_id] ) )
     319            $is_required[$field_id] = xprofile_check_is_required_field( $field_id );
     320            if ( $is_required[$field_id] && empty( $_POST['field_' . $field_id] ) )
    318321                $errors = true;
    319322        }
     
    327330            /* Now we've checked for required fields, lets save the values. */
    328331            foreach ( (array)$posted_field_ids as $field_id ) {
    329                 if ( !xprofile_set_field_data( $field_id, $bp->displayed_user->id, $_POST['field_' . $field_id] ) )
     332                if ( !xprofile_set_field_data( $field_id, $bp->displayed_user->id, $_POST['field_' . $field_id], $is_required[$field_id] ) )
    330333                    $errors = true;
    331334                else
     
    710713 * @return true on success, false on failure.
    711714 */
    712 function xprofile_set_field_data( $field, $user_id, $value ) {
     715function xprofile_set_field_data( $field, $user_id, $value, $is_required = false ) {
    713716    if ( is_numeric( $field ) )
    714717        $field_id = $field;
     
    719722        return false;
    720723
    721     if ( empty( $value ) || !strlen( trim( $value ) ) )
     724    if ( $is_required && ( empty( $value ) || !strlen( trim( $value ) ) ) )
    722725        return false;
    723726
Note: See TracChangeset for help on using the changeset viewer.