Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/07/2017 06:38:57 PM (7 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/tests/phpunit/testcases/members/class-bp-signup.php

    r9819 r11630  
    6363
    6464    /**
     65     * @group add
     66     */
     67    public function test_add_no_visibility_level_set_should_use_default_visiblity_level() {
     68        // Update field_1's default visiblity to 'adminsonly'
     69        bp_xprofile_update_field_meta( 1, 'default_visibility', 'adminsonly' );
     70
     71        // Add new signup without a custom field visibility set for field_1.
     72        $signup = BP_Signup::add( array(
     73            'domain' => 'foo',
     74            'path' => 'bar',
     75            'title' => 'Foo bar',
     76            'user_login' => 'user1',
     77            'user_email' => 'user1@example.com',
     78            'registered' => bp_core_current_time(),
     79            'activation_key' => '12345',
     80            'meta' => array(
     81                'field_1' => 'Foo Bar',
     82                'meta1' => 'meta2',
     83                'password' => 'password',
     84
     85                /*
     86                 * Ensure we pass the field ID.
     87                 *
     88                 * See bp_core_activate_signup() and BP_Signup::add_backcompat().
     89                 */
     90                'profile_field_ids' => '1'
     91            ),
     92        ) );
     93
     94        // Activate the signup.
     95        $activate = BP_Signup::activate( (array) $signup );
     96
     97        // Assert that field 1's visibility for the signup is still 'adminsonly'
     98        $vis = xprofile_get_field_visibility_level( 1, $activate['activated'][0] );
     99        $this->assertSame( 'adminsonly', $vis );
     100    }
     101
     102    /**
    65103     * @group get
    66104     */
Note: See TracChangeset for help on using the changeset viewer.