In Loki We Trust The many projects of Lokkju, Inc


Import all WordPress users into phpBB3

A task I had to pull off as part of some improvements I'm making for, we had to move all the existing WordPress users over to phpBB3, keeping the passwords and the like.

Luckily, this is made relatively easy, because they use the same hashing library, though different default hashes. The following script hasn't been extensively tested, but it worked for me. That said, I also had to bang this out in just a few minutes, and it requires both your WordPress and phpBB3 instances use the same database.


define('IN_PHPBB', true);
define('ROOT_PATH', "/path/to/forum");

$phpEx = substr(strrchr(__FILE__, '.'), 1);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : ROOT_PATH . '/';

include($phpbb_root_path . 'common.' . $phpEx);
require($phpbb_root_path ."includes/functions_user." . $phpEx);

function init() {
	global $db;
	global $user;
	global $auth;
	global $default_group_id;


	$sql = 'SELECT group_id FROM ' . GROUPS_TABLE . " WHERE group_name = 'REGISTERED' AND group_type = " . GROUP_SPECIAL;
	$result = $db->sql_query($sql);
	$row = $db->sql_fetchrow($result);
	$default_group_id = $row['group_id'];

function walk_wp_users() {
	global $phpbb_root_path;
	global $phpEx;
	global $db;
	global $config;
	global $user;
	global $auth;
	global $cache;
	global $template;
	global $default_group_id;
	$sql = 'SELECT user_login,user_pass,user_email,user_registered,user_activation_key FROM wp_users';
	$result = $db->sql_query($sql);
	while ($row = $db->sql_fetchrow($result))
		echo "processing '" . $row['user_login'] . "' ";
		$error = validate_username($row['user_login']);
		if ($error && $error == 'USERNAME_TAKEN') {
			echo "exists\n";
		} elseif ($error){
		} else {
			$user_row = array(
				'username'              => $row['user_login'],
				'user_password'         => $row['user_pass'],
				'user_email'            => $row['user_email'],
				'group_id'              => $default_group_id,
				'user_timezone'         => '-8',
				'user_dst'              => 0,
				'user_lang'             => 'en',
				'user_type'             => (($row['user_activation_key']) ? USER_INACTIVE : USER_NORMAL),
				'user_actkey'           => $row['user_activation_key'],
				'user_ip'               => '',
				'user_regdate'          => strtotime($row['user_registered']),
				'user_inactive_reason'  => (($row['user_activation_key']) ? INACTIVE_REGISTER : null),
				'user_inactive_time'    => time(),
			$user_id = user_add($user_row);
			echo "added as $user_id\n";



Comments (10) Trackbacks (0)
  1. Exactly what I needed. I’ll just have to edit it as they are in different databases but that should be fairly trivial. Thanks.

  2. Very good script ! I have just cut and past it and change
    define(‘ROOT_PATH’, “/path/to/forum”); and its work immediatelly !!

    Password for users tranfered succesfully too !
    Many thanks for your share.

  3. Just another comment : If you use the “NEWLY_REGISTERED” group in your forum you can modify the first sql query by :

    $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . " WHERE group_name = 'NEWLY_REGISTERED' AND group_type = " . GROUP_SPECIAL;

    But you have to run the query bellow after import to set the “new_user” parameter to 1 into the phpbb_users table.

    UPDATE `phpbb_users` SET `user_new`='1' WHERE user_ip = "" and user_posts =0

    hope it helps

  4. the script code above, where is it executed from?

    in phpmyadmin as a query?

    i tried it and get syntax errors, i just assume im doing it in the wrong place

  5. How to import all phpbb user into wordpress???????????

  6. Is there any version/edit of this for wordpress and phpbb being on different databases?

  7. Ok , Im new to all of this , So can anyone explain where should I edit this code ??


  8. Thanks for your help, it worked great !!!

    On Debian, the PHPBB path is ‘/usr/share/phpbb3/www’.

    So I created a file in wp-admin folder, called it sync.php, and changed the variable.

    Then I just called the page (, and it worked !!

    Thanks again

  9. It onley imported 283 accounts, i got 1099 WordPress users.
    Why doesnt it import all?

  10. You helped me a lot. Thank you very much.

Leave a comment

No trackbacks yet.

store profile