Page 2 of 3

Re: How to sync WP role to phpBB group?

Posted: Wed Oct 17, 2018 9:38 pm
by tlagren
Actually both the transfer process and new registration. Today we have 2000+ users in Joomla and use a bridge with phpBB but we're moving to Wordpress and want to keep phpBB. I already managed to transfer all users into Wordpress and since we used several groups in Joomla I converted them into roles in Wordpress. I'm using the WP-Members plugin to have support for custom registration, fields and roles. WP-Members stores all it's information in the standard Wordpress usermeta table which is nice.

So with this setup I'm able to assign different roles to my users and can manage their permissions based on those roles. In phpBB we already have a complex permission structure with groups where users can be member in several phpBB groups.

So basically what I try to achieve is to have the feature to managing all permissions in Wordpress by assigning several roles to the users and have that synchronized to phpBB.

Here's an example how the role membership looks in the database in Wordpress when WP-Members stored this.

Code: Select all

mysql> SELECT meta_value FROM wp_usermeta WHERE user_id = '2237' AND meta_key = 'wp_capabilities';
+-------------------------------------------------------------------------------+
| meta_value                                                                    |
+-------------------------------------------------------------------------------+
| a:3:{s:11:"klubbmedlem";b:1;s:14:"styrelsemedlem";b:1;s:10:"guldmedlem";b:1;} |
+-------------------------------------------------------------------------------+
1 row in set (0.00 sec)
This seems to be a serialized string which displays like this.
Btw. these strange role names are different member levels in the Swedish language :-)

Code: Select all

[tomas@laptop ~]$ php <<EOF
> <?php print_r(unserialize('a:3:{s:11:"klubbmedlem";b:1;s:14:"styrelsemedlem";b:1;s:10:"guldmedlem";b:1;}')); ?>
> EOF
Array
(
    [klubbmedlem] => 1
    [styrelsemedlem] => 1
    [guldmedlem] => 1
)
/Tomas

Re: How to sync WP role to phpBB group?

Posted: Wed Oct 17, 2018 11:06 pm
by axew3
I migrated a same scenario days ago, after all the rest done jet, i'll migrate some of lacking posts/topics between the old domain and the new domain on coming Saturday night, to adjust the new board adding all latest posts/topics done on the old domain forum in between update time in the other domain, and just before presentation to site owners. They have just registered users.

To add an user into phpBB and more then one group is required to add a line of code in places i indicate on above post.
To code something that can be switched between different memberships configurations may isn't complicate, offering options about this for any scenario, i need to take a more deep look into before to be sure about the fact that would be easy offer options on plugin admin page about this.

If you want synchronized in the way that, let say x example an user register in wp and is added in phpbb (also in more then one group), but after the user is promoted to some other group in Wordpress and you need it also updated to related group in phpBB, not possible with code as is.
As is, the plugin code completely ignore groups except in the time they register, or they are transferred. An exception is for WP users, that if deactivated in phpBB side, then same deactivated users, when visiting/login wp side are switched to belong to no group in WP and consequently logged out if the case. If reactivated in phpBB, they are reactivated in WP as registered when the will visit as logged or login wp side.

In the while you should may show mysql dump of the phpbb_groups table, structure and data, and maybe something else, but it depend on how you configured phpBB.
If you provide the above here, may i will try to give you the solution.

(if needed more advanced assistance or features, you'll may need to contact me in different way because the plugin not contain code for scenario like the example i mentioned above, almost at this time. By the way i will put on queue and i will take a look to implement if possible by default, but i can't grant about when this feature will be in case added).

Re: How to sync WP role to phpBB group?

Posted: Thu Oct 18, 2018 7:23 pm
by tlagren
Thanks for spending your time on this. I understand this may not be a common use case so I have full respect if you answer that this is out of the scope of your plugin. A workaround for us would be to use your plugin to add the WP users into phpBB and then manually in phpBB add them to correct groups.

I've sent you a mysqldump of the groups table in a private message.

/Tomas

Re: How to sync WP role to phpBB group?

Posted: Fri Oct 19, 2018 7:17 am
by axew3
Please specify which groups the wp user need to be added into, between existent in phpBB, and which of those you want resulting as the default group for users. List groups names and the default one you want.

Re: How to sync WP role to phpBB group?

Posted: Sun Oct 21, 2018 8:56 am
by tlagren
The default group in phpBB would be REGISTERED (id 3059).

Here are two examples of while role in WP that should be mappet to phpBB group.

WP role klubbmedlem should match phpBB group tacs_medlemmar (id 265).
WP role styrelsemedlem should match phpBB group styrelsemedlem (id319).

/Tomas

Re: How to sync WP role to phpBB group?

Posted: Sun Oct 21, 2018 10:29 am
by tlagren
Hi again, the best would be a role-to-group-mapping function in the admin settings or similar where the WP Admin could choose which roles should be mapped to phpBB groups.

/Tomas