Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/07/2017 06:38:57 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 (trunk)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-members/bp-members-functions.php

    r11611 r11630  
    20732073                }
    20742074
    2075                 // Save the visibility level.
    2076                 $visibility_level = ! empty( $user['meta']['field_' . $field_id . '_visibility'] ) ? $user['meta']['field_' . $field_id . '_visibility'] : 'public';
     2075                /*
     2076                 * Save the visibility level.
     2077                 *
     2078                 * Use the field's default visibility if not present, and 'public' if a
     2079                 * default visibility is not defined.
     2080                 */
     2081                $key = "field_{$field_id}_visibility";
     2082                if ( isset( $user['meta'][ $key ] ) ) {
     2083                    $visibility_level = $user['meta'][ $key ];
     2084                } else {
     2085                    $vfield           = xprofile_get_field( $field_id );
     2086                    $visibility_level = isset( $vfield->default_visibility ) ? $vfield->default_visibility : 'public';
     2087                }
    20772088                xprofile_set_field_visibility_level( $field_id, $user_id, $visibility_level );
    20782089            }
Note: See TracChangeset for help on using the changeset viewer.