Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/07/2017 06:37:55 PM (8 years ago)
Author:
r-a-y
Message:

Activation: Ensure we use the XProfile field's default visibility level during activation.

Previously, if the visibility option for a XProfile field was removed from
the registration template, the visibility level for the user would always
fallback to 'public' instead of what the actual XProfile field's default
visibility level was.

Commit includes a unit test and rectifies the problem.

Props uscore713.

Fixes #7553 (2.8-branch)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.8/src/bp-members/classes/class-bp-signup.php

    r11240 r11629  
    389389                    xprofile_set_field_data( $field_id, $user_id, $current_field );
    390390
    391                     // Save the visibility level.
    392                     $visibility_level = ! empty( $usermeta['field_' . $field_id . '_visibility'] ) ? $usermeta['field_' . $field_id . '_visibility'] : 'public';
     391                    /*
     392                     * Save the visibility level.
     393                     *
     394                     * Use the field's default visibility if not present, and 'public' if a
     395                     * default visibility is not defined.
     396                     */
     397                    $key = "field_{$field_id}_visibility";
     398                    if ( isset( $usermeta[ $key ] ) ) {
     399                        $visibility_level = $usermeta[ $key ];
     400                    } else {
     401                        $vfield           = xprofile_get_field( $field_id );
     402                        $visibility_level = isset( $vfield->default_visibility ) ? $vfield->default_visibility : 'public';
     403                    }
    393404                    xprofile_set_field_visibility_level( $field_id, $user_id, $visibility_level );
    394405                }
Note: See TracChangeset for help on using the changeset viewer.