#1889 closed enhancement (fixed)
Option to delete imported users when performing 'Reset Forum'
Reported by: | netweb | Owned by: | johnjamesjacoby |
---|---|---|---|
Milestone: | 2.5 | Priority: | normal |
Severity: | normal | Version: | 2.0 |
Component: | API - Importers | Keywords: | dev-feedback needs-testing |
Cc: | jared@… |
Description
When you perform a 'Reset Forums' all forums/topics/replies are removed as is the importers conversion table (bbprc4_bbp_converter_translator), this leaves all imported users as standard WordPress users with all bbPress metadata removed from the user.
Because the conversion table is now gone you have no way to delete the imported users as there is no longer a record of what users were imported.
Thus when performing a 'Reset Forums' should there also be an option to also delete these users during this process to remove them whilst bbPress still knows something about these users?
I don't think this behavior should be forced as default as there would be use cases where you do want to actually keep all the users as standard WordPress users if you were to longer use bbPress for example but still wanted the users user/pass to stay in the system.
Attachments (2)
Change History (20)
#2
@
12 years ago
- Summary changed from Option to delete imported users when performing 'Rest Forum' to Option to delete imported users when performing 'Reset Forum'
#5
in reply to:
↑ 4
@
12 years ago
Replying to jaredatch:
This sounds pretty easy, is there some user meta data that can be used to only delete users that were imported (and not users that were created outside the importer)?
Could look for '_bbp_user_id' in usermeta.
#6
@
12 years ago
Does anyone have an export I can use for testing so I don't have to manually add the usermeta?
#7
@
12 years ago
Jared,
How about a SQL database of BuddyPress with Group Forums with some sample data?
That way you can re-run the import as often as you need to import users etc
#9
@
12 years ago
- Milestone changed from 2.3 to 2.4
Moving to 2.4 so we can focus on importers then. If an urgent/compelling patch comes in, we can sneak this in to 2.3.
#11
@
11 years ago
_bbp_user_id
is wp_usermeta
only exists if the user was imported and the code already exists in the importer when selecting 'Purge Previous Import' it 'should' remove imported users.
(I say should but for some reason it isn't at the moment, will create a ticket for this shortly)
http://bbpress.trac.wordpress.org/browser/trunk/includes/admin/converter.php#L1083
#12
@
11 years ago
- Keywords dev-feedback needs-testing added
In 1889.diff an option to delete imported users has been added to 'Reset Forums' (see 1889.png)
If the option IS checked any imported user with a wp_usermeta
entry _bbp_user_id
will be deleted from wp_users
& wp_usermeta
and cannot be undone.
If the option is NOT checked only bbPress meta properties (%_bbp_%
) for that user will be removed from wp_usermeta
Optionally we could leave (or copy/rename the key) _bbp_user_id
assigned to the user_id
and this would allow 'Reset Forums' to be run subsequent times to delete imported users. Typically if an import fails and you want to start from scratch you would always delete the imported users. A use case for only resetting the forums without deleting the imported users I cannot think of off the top of my head.
#13
@
11 years ago
If BuddyPress is activated user data in wp_bp_xprofile_data
is not deleted as we delete users directly from _users
& _usermeta
using SQL DELETE FROM
statements in 1889.diff
.
Maybe include some if exists checks for BuddyPress after _usermeta
is deleted:
$exists_bp_xprofile_data = $wpdb->prefix . 'wp_bp_xprofile_data';
if ( $wpdb->get_var( "SHOW TABLES LIKE '{$exists_bp_xprofile_data }'" ) === $exists_bp_xprofile_data ) {
$sql_delete = "DELETE FROM `{$wpdb->wp_bp_xprofile_data}` WHERE `user_id` IN ('{$sql_meta}');";
$result = is_wp_error( $wpdb->query( $sql_delete ) ) ? $failed : $success;
$messages[] = sprintf( $statement, $result );
}
#14
@
11 years ago
That's an interesting problem with us doing direct queries. It's probably something BuddyPress should have built into itself eventually, and I'm fine not including BuddyPress specific direct queries in bbPress until then.
#15
@
11 years ago
I have a PHP error in 1889.diff and I am not sure what or why
On line 1187 of the patch $sql_meta[] = $key;
breaks the patch and I know it is something I am doing wrong, just what it is I do not know.
At this stage using the attached patch, if you check the box to delete the imported users it fails, click back in your browser and submit again and it works and deletes the imported users. :P
This sounds pretty easy, is there some user meta data that can be used to only delete users that were imported (and not users that were created outside the importer)?