Switch WP user to specified Group in phpBB, when Role updated in WordPress and vice versa

WP_w3all phpBB integration 2.6.8> option

Read all the follow before to activate the option

Basic default WP Roles and phpBB groups switches will work as follow by default, if no custom file provided:

When an admin in WordPress update an user Role, or Role change due to user’s subscriptions:

Editor in WP or Woocommerce Shop Manager, will be added into the Global Moderator group as primary group in phpBB, the previous primary user’s group membership will be removed.
Author, Contributor or Subscriber or Woocommerce customer, will be added into the Registered group in phpBB, the previous primary group membership will be removed.
Administrator in WP will be set as Administrator in phpBB (not with all founder’s powers), the previous primary user’s group membership will be removed. The User with No role in WP will be deactivated in phpBB.

When an user change/update group in phpBB:

If belong as default group to the Registered phpBB group, will be updated in WP to Subscriber and the previous primary Role removed.

If belong as default group to the Global Moderators phpBB group, will updated in WP to Editor and the previous primary Role removed.

Administrators in this case are not considered by default. But you can activate the code about, into

the file wp-content/plugins/wp-w3all-phpbb-integration/common/wpRoles_phpbbGroups.php . It contain the code that can be customized as more like to get complex WP Roles and phpBB Groups switches. It already contain basic code example and basic hints. Advanced wp coders will find out that’s quite easy to write owns code snippets and achieve any kind of complex Roles/Groups switches.

How i can customize the file wpRoles_phpbbGroups.php expecting that when the integration plugin will update, modifications done into this file aren’t lost?

Create a folder (if you did not it already, activating the custom /views files option) named wp-w3all-custom inside the folder /wp-content/plugins/ so you’ll have /wp-content/plugins/wp-w3all-custom/

copy the file /wp-content/plugins/wp-w3all-phpbb-integration/common/wpRoles_phpbbGroups.php

and paste it inside the created folder, so you’ll have /wp-content/plugins/wp-w3all-custom/wpRoles_phpbbGroups.php

Custom files inside this folder, are not overwritten when the plugin will be updated (like all the custom views files).

Note that the option Use custom files to display Last Topics Widgets, Login Widget and Shortcodes do not affect this. If the custom file /wp-content/plugins/wp-w3all-custom/wpRoles_phpbbGroups.php exist, it will be included, even if the Use custom files to display Last Topics Widgets, Login Widget and Shortcodes option is set to No.

Advanced and common hints

Where the wpRoles_phpbbGroups.php file is included?

About an Admin that update an user role (the update will be synchronous)

Open: /wp-content/plugins/wp-w3all-phpbb-integration/class.wp.w3all-phpbb.php

search for:

inside

public static function phpbb_update_profile($user_id, $old_user_data) {

About a current WP logged in user updates (the update will be asynchronous)

an user that changed Group in phpBB side** and that so will be updated to the related WP Role when as logged in will visit WordPress, search for:

into /wp-content/plugins/wp-w3all-phpbb-integration/class.wp.w3all-phpbb.php

inside the function verify_phpbb_credentials()

About Memberpress or others external memberships plugins:

Remember: this is a WP plugin, it run ONLY in WP side! So it has been defined synchronous the Role update when done in WP side updating an user profile. In this case the update occur at same time in phpBB. It is asynchronous when the WP role change due to some other reason, for example due to some Role update that fire on the background, after a subscribed membership or something else, but the affected user is not currently logged in into WordPress.

It is also asynchronous if the user change profile’s data in phpBB, because until the same user will not visit the WP side as logged, no code will run to update his Role in WP.

Read more inline hints into the file wpRoles_phpbbGroups.php

Could be all synchronous? Yes, the result can be achieved in several ways, for any configuration or/and plugin/extension installed.

A One Way (WP to phpBB only) explained example is here (read all answers):

https://www.axew3.com/w3/forums/viewtopic.php?t=1806

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.