Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
262 views
in Q2A Core by
it may be from db or using other plugins

1 Answer

0 votes
by

First and foremost, before doing anything on the database level make sure you have a recent backup (and have verified that you can actually restore it). If possible, create a new backup before you start changing things in the database.

For merging 2 users in the database you'd identify all tables that have user ID information in them (most of them do):

SELECT DISTINCT table_name
  ,column_name
FROM information_schema.columns
WHERE (column_name LIKE '%userid' OR column_name LIKE '%user_id')
  AND table_schema = 'FOOBAR'
  AND table_name != 'qa_users';

Replace "FOOBAR" in that query with your actual database name.

Then update the fields containing the ID of the second account with the ID of the first account.

UPDATE qa_blobs SET userid=23 WHERE userid=42;

Replace 23 and 42 with the correct user IDs (and of course adjust table and column names as needed).

You may want to wrap all updates in a transaction, so that a) you can roll back if something goes wrong in the process, and b) users and applications won't see modified data before the transaction is completed.

BEGIN TRANSACTION;
UPDATE qa_blobs SET userid=23 WHERE userid=42;
UPDATE qa_eventlog SET userid=23 WHERE userid=42;
...
COMMIT;

In the web interface verify that the merged user (ID 42 in the above examples) doesn't have any posts associated with them anymore, then delete that user.

I'm not aware of a plugin that would simplify these steps.

...