Transfer large number of users from phpBB to WP

bson
User w
User w
Posts: 5
Joined: Thu Feb 03, 2022 2:48 pm

Transfer large number of users from phpBB to WP

Post by bson »

Hi!

I'm impressed by your WP plugin and it works great. However, we have a case where we would like to transfer around 1000 specific users from phpBB to WP. These specific user emails can be kept in a file or in a SQL table. Is there some way of tweaking the "Transfer phpBB Users into WordPress" so that the transfered user are SQL joined with my own temporary table holding these 1000 emails?
User avatar
axew3
w3all User
w3all User
Posts: 2883
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Contact:

Re: Transfer large number of users from phpBB to WP

Post by axew3 »

Hello! When you find out any bug, report it, so it will be time by time improved!

You can transfer any amount of users per time, the unique limit is given by php.ini max execution time. So that may you can transfer 3000 or 5000 or 10000 users per time. After minutes you wait for browser that finish the task, you have to re-click.
It can be improved easily in short, adding js responses (so each processed user display on page) and without the need to click into the transfer button each step or the need to increase the php.ini. Sometime in next versions may it will be done.

You can create users taking data from anywhere, so yes it is possible with little changes.
But not sure i have understand the mean of the question.
Do you want that only users, which emails belongs to a list (stored into another table), are transferred into WP, while all the rest or the users discarded/not transferred in WP? Or what?

[EDITED]
bson
User w
User w
Posts: 5
Joined: Thu Feb 03, 2022 2:48 pm

Re: Transfer large number of users from phpBB to WP

Post by bson »

Yes, that's correct. I have a list of email addresses in a db table or in a file. I want to transfer all phpBB accounts in that table (or file) over to WordPress.
User avatar
axew3
w3all User
w3all User
Posts: 2883
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Contact:

Re: Transfer large number of users from phpBB to WP

Post by axew3 »

i am just doing a routine, that will cleanup from a db site usermeta millions of records, due to a wrong code applied by a guy time ago.
i am doing a delete of all records, and reload news, so just this part we assume is +- the same

assuming we have it into a file, data line by line, we get data:

Code: Select all

   // get the file data
   $filename = 'E:/custom/Garmin_SUBSCRIPTION_codes_1.6.22.csv';

   $fp = @fopen($filename, 'r');
    if ($fp) {
     $ary0 = explode(PHP_EOL, file_get_contents($filename));
    }
But this is the first part that is the unique equal.
Now you have the array of data: we assume you'll have emails and usernames and password? Or just emails? and the rest created random?

Code: Select all

$username

    (string) (Required) The user's username.
$password

    (string) (Required) The user's password.
$email

    (string) (Optional) The user's email.

    Default value: ''
assume you have all params username, password and email you'll just create a foreach where
the code will do something like this:

Code: Select all

$ck_wpun_exists = username_exists($username);
      $user_id = email_exists($user_email);

 if ( ! $user_id && ! $ck_wpun_exists ) { // this user do not exists in WP
               $role = 'subscriber';
              $userdata = array(
               'user_login'       =>  $username,
               'user_pass'        =>  $user_password,
               'user_email'       =>  $user_email,
              // 'user_registered'  =>  date_i18n( 'Y-m-d H:i:s', $user_regdate ), // if you do not pass this param, the registration date will be the date of the script execution
               'role'             =>  $role
               );
  
    $user_id = wp_insert_user( $userdata );             
  if ( is_wp_error( $user_id ) ) {
   echo 'user not added into Wp';
   } else {
   echo 'user ' .$user_id . ' added into Wp';
   }
There are several more things to think to that i not precised here, but generally this will work fine in any scenario.
I know it is not the complete code you want, just a stupid example that assume you are a almost little skilled on programming php and wp, but it need to be created in case. If you want follow asking for steps, i will of course answer here!

p.s if data dump files is really big, containing millions of users, this routine may require to pass a specified number of users each time, insert one by one, and coded to run step by step without breaking due to max execution time.
Very easy concept, but as said, it require to be coded. The browser will run for hours doing tasks like these for millions of records.
Do not know if via cli would be faster. I assume will be exactly the same.
bson
User w
User w
Posts: 5
Joined: Thu Feb 03, 2022 2:48 pm

Re: Transfer large number of users from phpBB to WP

Post by bson »

Thank you!

That's a good starting point to work on.
Post Reply