Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/29/2020 05:32:05 PM (5 years ago)
Author:
boonebgorges
Message:

Don't delete user data on delete_user hook on Multisite.

The new function bp_remove_user_data_on_delete_user_hook(), which defaults
to false on Multisite and true otherwise, helps BuddyPress to differentiate
between the use of wp_delete_user() to delete a user account from an
installation (typical on non-Multisite) and its use to remove a user from
a site in a Multisite instance.

Props imath.

Fixes #8175.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/xprofile/functions.php

    r12110 r12605  
    11321132        $this->assertSame( 3, count( $actual['data'][0]['data'] ) );
    11331133    }
     1134
     1135    /**
     1136     * @ticket BP8175
     1137     */
     1138    public function test_xprofile_data_should_be_deleted_on_user_delete_non_multisite() {
     1139        if ( is_multisite() ) {
     1140            $this->markTestSkipped( __METHOD__ . ' requires non-multisite.' );
     1141        }
     1142
     1143        $u = self::factory()->user->create();
     1144
     1145        $fg = self::factory()->xprofile_group->create();
     1146        $f1 = self::factory()->xprofile_field->create(
     1147            array(
     1148                'field_group_id' => $fg,
     1149            )
     1150        );
     1151
     1152        xprofile_set_field_data( $f1, $u, 'foo' );
     1153        $this->assertSame( 'foo', xprofile_get_field_data( $f1, $u ) );
     1154
     1155        wp_delete_user( $u );
     1156
     1157        $this->assertSame( '', xprofile_get_field_data( $f1, $u ) );
     1158    }
     1159
     1160    /**
     1161     * @ticket BP8175
     1162     */
     1163    public function test_xprofile_data_should_be_deleted_on_user_delete_multisite() {
     1164        if ( ! is_multisite() ) {
     1165            $this->markTestSkipped( __METHOD__ . ' requires multisite.' );
     1166        }
     1167
     1168        $u = self::factory()->user->create();
     1169
     1170        $fg = self::factory()->xprofile_group->create();
     1171        $f1 = self::factory()->xprofile_field->create(
     1172            array(
     1173                'field_group_id' => $fg,
     1174            )
     1175        );
     1176
     1177        xprofile_set_field_data( $f1, $u, 'foo' );
     1178        $this->assertSame( 'foo', xprofile_get_field_data( $f1, $u ) );
     1179
     1180        wpmu_delete_user( $u );
     1181
     1182        $this->assertSame( '', xprofile_get_field_data( $f1, $u ) );
     1183    }
     1184
     1185    /**
     1186     * @ticket BP8175
     1187     */
     1188    public function test_xprofile_data_should_not_be_deleted_on_wp_delete_user_multisite() {
     1189        if ( ! is_multisite() ) {
     1190            $this->markTestSkipped( __METHOD__ . ' requires multisite.' );
     1191        }
     1192
     1193        $u = self::factory()->user->create();
     1194
     1195        $fg = self::factory()->xprofile_group->create();
     1196        $f1 = self::factory()->xprofile_field->create(
     1197            array(
     1198                'field_group_id' => $fg,
     1199            )
     1200        );
     1201
     1202        xprofile_set_field_data( $f1, $u, 'foo' );
     1203        $this->assertSame( 'foo', xprofile_get_field_data( $f1, $u ) );
     1204
     1205        wp_delete_user( $u );
     1206
     1207        $this->assertSame( 'foo', xprofile_get_field_data( $f1, $u ) );
     1208    }
    11341209}
Note: See TracChangeset for help on using the changeset viewer.