Skip to:
Content

bbPress.org

Opened 12 years ago

Closed 11 years ago

Last modified 11 years ago

#1889 closed enhancement (fixed)

Option to delete imported users when performing 'Reset Forum'

Reported by: netweb's profile netweb Owned by: johnjamesjacoby's profile 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)

1889.diff (3.0 KB) - added by netweb 11 years ago.
1889.png (26.1 KB) - added by netweb 11 years ago.

Download all attachments as: .zip

Change History (20)

#1 @netweb
12 years ago

  • Type changed from defect to enhancement

#2 @netweb
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'

#3 @johnjamesjacoby
12 years ago

  • Milestone changed from Awaiting Review to 2.2

#4 follow-up: @jaredatch
12 years ago

  • Cc jared@… added

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)?

#5 in reply to: ↑ 4 @johnjamesjacoby
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 @jaredatch
12 years ago

Does anyone have an export I can use for testing so I don't have to manually add the usermeta?

#7 @netweb
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

#8 @jaredatch
12 years ago

Sure, I think that may work :)

#9 @johnjamesjacoby
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.

#10 @johnjamesjacoby
12 years ago

  • Milestone changed from 2.4 to 2.5

No time. Moving to 2.5.

#11 @netweb
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

@netweb
11 years ago

@netweb
11 years ago

#12 @netweb
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 @netweb
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 @johnjamesjacoby
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 @netweb
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

#16 @johnjamesjacoby
11 years ago

  • Owner set to johnjamesjacoby
  • Resolution set to fixed
  • Status changed from new to closed

In 5173:

When resetting the forums back to pre-import status, allow admins to delete imported users. This handles the clean up of a potentially botched import, while also helping revert a site back to a pre-bbPress configuration. Fixes #1889. Props netweb.

#17 @johnjamesjacoby
11 years ago

In 5174:

If not deleting users, delete the imported user meta-data instead. See #1889. Props netweb.

#18 @johnjamesjacoby
11 years ago

In 5175:

Mass hysteria. See #1889.

Note: See TracTickets for help on using tickets.