Ticket #7553: 7553.02.patch
File 7553.02.patch, 3.6 KB (added by , 7 years ago) |
---|
-
src/bp-members/bp-members-functions.php
2072 2072 xprofile_set_field_data( $field_id, $user_id, $current_field ); 2073 2073 } 2074 2074 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 } 2077 2088 xprofile_set_field_visibility_level( $field_id, $user_id, $visibility_level ); 2078 2089 } 2079 2090 } -
src/bp-members/classes/class-bp-signup.php
388 388 $current_field = $usermeta["field_{$field_id}"]; 389 389 xprofile_set_field_data( $field_id, $user_id, $current_field ); 390 390 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 } 393 404 xprofile_set_field_visibility_level( $field_id, $user_id, $visibility_level ); 394 405 } 395 406 } -
tests/phpunit/testcases/members/class-bp-signup.php
62 62 } 63 63 64 64 /** 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 /** 65 103 * @group get 66 104 */ 67 105 public function test_get_with_offset() {