We have recently switched our forum software from SMF (Simple Machines Forum) to Kunena. This was planned anyway to get an integrated user experience, but the recent switch to Joomla 3.5 and PHP 7 forced the process. As there were no migration tools available for SMF -> Kunena migration I had to write my own script to migrate the users and all posts from SMF 2.0 to Joomla! 3.5 and Kunena 4.0. It worked great and I chose to publish the scripts in hope it will help others with their data migration. The script is available on GitHub as SMF2Kunena so feel free to download, use and modify it for your needs.
In this blog post I will cover the user migration in detail. For the rest of the process you can consult the README file and the source code on GitHub.
Preparations
We will use a CLI (Command Line Interface) script for data conversion. Why CLI? It's more convenient than web accessed script because we don't want the data conversion to be publicly available and incidentally executed. We also avoid the various limitations like memory limit and max processing time that could prevent us from running long and heavy tasks.
To be able to use it you must have access to command line through terminal or shell (SSH), if you do it on remote server. It is recommended that you do the process locally though, because of the speed and better overview. Copy the file forum_migrate.php to the cli/ directory of your Joomla installation. Then you will be able navigate to cli/ directory and simply execute the script by typing the command:
php forum_migrate.php
You need to make sure the php short command points to the correct php installation, with the access to your database. This is particularly important if you do the process locally.
The script assumes an empty Joomla! user base. All users from SMF will be added, it will not update any existing users. If there are existing users with the same username or email address, it will skip importing them. Thus, it's best if you start on an empty Joomla! installation (with only Super User).
Make sure your SMF database tables are added to the same database as Joomla uses. These tables will normally have "smf_" prefix which will separate them from the rest of your tables.
Now it's a good time to make a database dump so we have a backup that we can import in case anything goes wrong.
Users migration
Open the file forum_migrate.php and uncomment the following code:
$this->out('Migrating users...'); $this->_migrateUsers(); $this->out('Done migrating users.');
Execute the script and it will import all users. It will basically do a Joomla user registration for each of your SMF users using the name, username and email and it will copy their password hash, registered and last visit dates.
Note that this process may take several minutes depending on how many users you have. After it's done you can verify that users are added by going to Joomla! users manager.
Authentication plugin
Since SMF uses different hashing algorithm for user passwords than Joomla does, none of your users will be able to login at this point. We can't use the hash to recover original password either so we can't generate the correct password hash required for Joomla! authentication.
So what can we do? Fortunately, additional authentication methods can be added to Joomla! in form of authentication plugins. We will install a new authentication plugin which will check if the entered password matches the SMF hash according to its algorithm and, if it does, authenticate the user. The plugin will also replace the hash with the Joomla! password hash at this point so the original Joomla! authentication will work next time.
This way your old SMF users will be able to login normally and there will be no interruptions in the service like needing to go through the password changes or anything like that. Of course, users will be able to reset their password normally if they forgot it.
The plugin is on GitHub in the "plg_smf" folder. You can either zip the content of this folder and install it through Joomla! extension manager, or install it directly from the directory. Don't forget to enable the plugin, it's called Authentication - SMF.
Other data
You can find information about the rest of the conversion process (user profiles, boards, topics, posts etc.) in the README file and the source code on GitHub. I hope that the source code can come handy and give you a head start even if you are converting some other type of data to Joomla! database. Good luck with your data migration!