# Importing phpBB group/forum permissions

**URL:** <https://meta.discourse.org/t/importing-phpbb-group-forum-permissions/26456>\
**Category:** Migration\
**Tags:** phpbb\
**Created:** [17 Marzo 2015, 10:54pm UTC](https://meta.discourse.org/t/importing-phpbb-group-forum-permissions/26456 "2015-03-17T22:54:14Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![casey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/casey/32/115495_2.png) [@casey](https://meta.discourse.org/u/casey)\
**Post date:** [17 Marzo 2015, 10:54pm UTC](https://meta.discourse.org/t/importing-phpbb-group-forum-permissions/26456/1 "2015-03-17T22:54:14Z")

</div>

I’ve been able to run the excellent import script for phpBB and get most of the content moved over with a few tweaks for our situation.

Thanks to @neil and everyone who had a hand in the script. I’ve made an addition to the script for placing the imported users into their respective groups also. I’ll add this to the official git and make a pr. Code at the end of message for review.

Has anyone had any luck with importing the phpBB3 group to forum permissions into Discourse as group to category permissions? I’m importing 123 forums so it’d be great if someone else had already knocked this out. I’ve searched meta but found nothing.

Importing user/group data:

```ruby
def put_users_in_groups
   # group_id 4 and 5 are taken care of in import_users 

    puts '', "adding users to groups"
    progress_count = 0
    total_count = mysql_query("SELECT count(*) count
                                 FROM amazingc_forum.phpbb_user_group ug
                                join phpbb_groups g on g.group_id = ug.group_id
                                join phpbb_users u on u.user_id = ug.user_id
                                AND ug.group_id NOT IN (4,5);").first['count']

    batches(BATCH_SIZE) do |offset|
      results = mysql_query(
        "SELECT u.user_id, g.group_id
          FROM amazingc_forum.phpbb_user_group ug
          join phpbb_groups g on g.group_id = ug.group_id
          join phpbb_users u on u.user_id = ug.user_id
          AND ug.group_id NOT IN (4,5)
          order by user_id
          LIMIT #{BATCH_SIZE}
         OFFSET #{offset};")

      break if results.size < 1

      results.each do |users_group|
        begin
          current_user = find_user_by_import_id(users_group["user_id"])
          current_group = group_id_from_imported_group_id(users_group["group_id"])
          progress_count += 1
          print_status(progress_count, total_count)

          next if current_user.nil?
          next if current_group.nil?

          GroupUser.find_or_create_by(user: current_user, group_id: current_group)
        rescue SystemCallError => err
          puts "Couldnt add user to group: #{err.message}"
        end
      end
    end
  end

```

---

_[View the full topic](https://meta.discourse.org/t/importing-phpbb-group-forum-permissions/26456)._
