• Resolved swelljoe

    (@swelljoe)


    I have several custom Drupal modules that I’m porting to WordPress where the backing data uses the Drupal UID. Worse, there’s a decade worth of emails with the old user ID in links and such for users to retrieve their licenses and order information and such. Keeping UIDs the same has *really* high value for my use case. I got the Premium version hoping it’d give me some extra options in this area, but no such luck.

    I see I can get the original UID from the wp_usermeta table (meta_key = ‘_fgd2wp_old_user_id’), but I can’t see any technical reason why UIDs need to change at all (assuming the migration is starting with a clean slate with no existing users), and it’s going to require a lot of code to work around it in all the ways I need to work around it. So, hoping there’s maybe a simple tweak to just skip all the mapping to new UIDs stuff and have it keep the old IDs?

Viewing 1 replies (of 1 total)
  • Thread Starter swelljoe

    (@swelljoe)

    Nevermind, I figured out a hacky solution, which seems to have worked.

    I added the following in admin/class-fg-drupal-to-wp-users.php in add_user (just before and in the $userdata definition):

    
    // Hacky make a user directly in db to force an ID
    global $wpdb;
    $wpdb->insert( $wpdb->users, array( 'ID' => $drupal_user_id', 'user_login' => $login  ));
    
    // Update it with the Drupal user data
    $userdata = array(
    'ID' => $drupal_user_id,
    ...
    

    This leads to keeping the Drupal uid as the WordPress ID, and in the usermeta table, the user_id is the same as the _fgd2wp_old_user_id, which seems to make page/post migrations work as expected). I’m migrating 40,000 users, so it’s not done yet, but the ones I’ve checked seemed to work, so as long as there are no dupes I think it’ll be fine.

    • This reply was modified 3 years, 10 months ago by swelljoe.
    • This reply was modified 3 years, 10 months ago by swelljoe.
Viewing 1 replies (of 1 total)
  • The topic ‘Is it possible to keep UIDs the same across the migration?’ is closed to new replies.