diff --git src/wp-includes/user.php src/wp-includes/user.php
index d6075ca5a9..50fc815bff 100644
|
|
function wp_insert_user( $userdata ) { |
1754 | 1754 | |
1755 | 1755 | $meta['use_ssl'] = empty( $userdata['use_ssl'] ) ? 0 : (bool) $userdata['use_ssl']; |
1756 | 1756 | |
1757 | | $meta['show_admin_bar_front'] = empty( $userdata['show_admin_bar_front'] ) ? 'true' : $userdata['show_admin_bar_front']; |
| 1757 | $meta['show_admin_bar_front'] = !isset( $userdata['show_admin_bar_front'] ) ? 'true' : $userdata['show_admin_bar_front']; |
1758 | 1758 | |
1759 | 1759 | $meta['locale'] = isset( $userdata['locale'] ) ? $userdata['locale'] : ''; |
1760 | 1760 | |
diff --git tests/phpunit/tests/user.php tests/phpunit/tests/user.php
index 74c533b69d..2c07a1bcf4 100644
|
|
class Tests_User extends WP_UnitTestCase { |
969 | 969 | $this->assertSame( $expected, $user->user_nicename ); |
970 | 970 | } |
971 | 971 | |
| 972 | /** |
| 973 | * @ticket 49087 |
| 974 | */ |
| 975 | public function test_wp_insert_user_with_bool_false_show_admin_bar_front() { |
| 976 | $u = wp_insert_user( |
| 977 | array( |
| 978 | 'user_login' => 'whatever', |
| 979 | 'user_email' => 'whatever@example.com', |
| 980 | 'user_pass' => 'password', |
| 981 | 'show_admin_bar_front' => false, |
| 982 | ) |
| 983 | ); |
| 984 | |
| 985 | $this->assertNotEmpty( $u ); |
| 986 | $user = new WP_User( $u ); |
| 987 | $this->assertNotEquals( 'true', $user->get( 'show_admin_bar_front' ) ); |
| 988 | } |
| 989 | |
| 990 | /** |
| 991 | * @ticket 49087 |
| 992 | */ |
| 993 | public function test_wp_insert_user_with_string_false_show_admin_bar_front() { |
| 994 | $u = wp_insert_user( |
| 995 | array( |
| 996 | 'user_login' => 'whatever', |
| 997 | 'user_email' => 'whatever@example.com', |
| 998 | 'user_pass' => 'password', |
| 999 | 'show_admin_bar_front' => 'false', |
| 1000 | ) |
| 1001 | ); |
| 1002 | |
| 1003 | $this->assertNotEmpty( $u ); |
| 1004 | $user = new WP_User( $u ); |
| 1005 | $expected = 'false'; |
| 1006 | $this->assertSame( $expected, $user->get( 'show_admin_bar_front' ) ); |
| 1007 | } |
| 1008 | |
972 | 1009 | /** |
973 | 1010 | * @ticket 28004 |
974 | 1011 | */ |