I’m trying to import users and data into my app.
The data for a user is build and saved like this:
$data = [ 'id' => $user['ID'], 'username' => $user['user_nicename'], 'email' => $user['user_email'], 'password' => $user['user_pass'], 'created' => $user['user_registered'], 'users_detail' => [ 'firstname' => $user['user_nicename'], 'lastname' => '' ], 'roles' => [ ['id' => $memberRole->id] ] ]; $usersEntity = $usersTable->newEntity($data); $usersTable->save($usersEntity);
The user is inserted just fine except with one issue: the
id is just plainly ignored and keeps following the
autoincrement from the database.
Is there a way to insert the user with the proper ID?
Just rolling with it like this will complicate matters a lot as now the data from the other tables I need to migrate won’t align with the users at all (eg. the user with
id=3 in the database actually is known with
id=9, the one with
id=4 in the database actually is known with