Skip to:
Content

BuddyPress.org

Changeset 7150


Ignore:
Timestamp:
06/04/2013 01:45:23 PM (11 years ago)
Author:
boonebgorges
Message:

Populate registration field visibility settings from $_POST, if available

By giving preference to values in the $_POST global when populating the profile
field visibility settings on the registration page, we ensure that users who
modify those values and then submit a failed registration do not have to
reenter the values after the page reloads.

See #4958

Props dcavins

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-xprofile/bp-xprofile-template.php

    r7122 r7150  
    749749        global $field;
    750750
    751         $retval = !empty( $field->visibility_level ) ? $field->visibility_level : 'public';
     751        // On the registration page, values stored in POST should take
     752        // precedence over default visibility, so that submitted values
     753        // are not lost on failure
     754        if ( bp_is_register_page() && ! empty( $_POST['field_' . $field->id . '_visibility'] ) ) {
     755            $retval = esc_attr( $_POST['field_' . $field->id . '_visibility'] );
     756        } else {
     757            $retval = ! empty( $field->visibility_level ) ? $field->visibility_level : 'public';
     758        }
    752759
    753760        return apply_filters( 'bp_get_the_profile_field_visibility_level', $retval );
     
    766773        global $field;
    767774
    768         $level  = !empty( $field->visibility_level ) ? $field->visibility_level : 'public';
     775        // On the registration page, values stored in POST should take
     776        // precedence over default visibility, so that submitted values
     777        // are not lost on failure
     778        if ( bp_is_register_page() && ! empty( $_POST['field_' . $field->id . '_visibility'] ) ) {
     779            $level = esc_html( $_POST['field_' . $field->id . '_visibility'] );
     780        } else {
     781            $level = ! empty( $field->visibility_level ) ? $field->visibility_level : 'public';
     782        }
     783
    769784        $fields = bp_xprofile_get_visibility_levels();
    770785
Note: See TracChangeset for help on using the changeset viewer.