axew3.com

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

by

WP_w3all phpBB integration 2.6.8> option

Read all the follow before to activate the option

# The groups/roles integration can be complex as more like
# It is substantially quite hard to put here any possible combination of things expecting that it will fit the required for any possible scenario.
# This file (wpRoles_phpbbGroups.php) can be edited as more like, and can be copied into the 'wp-content/plugins/wp-w3all-custom/wpRoles_phpbbGroups.php' folder
# so that when the plugin will update, custom modifications will not be lost

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 a WP 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:

if( $w3all_link_roles_groups

inside

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

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:

if($w3all_link_roles_groups >

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:

  // **** MemberPress note: do not know if it is a bug of the version 10 Legacy i am testing on, or a default behavior, but when an user is set as NoRole in WordPress, WP set/leave the user as subscriber by the way.
  // So that it is necessary to detect that the user may have not an active mepr subscriptions/memberships and deactivate or move the user into another group in phpBB if the case

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

# The groups/roles integration can be complex as more like
# It is substantially quite hard to put here any possible combination of things expecting that it will fit the required for any possible scenario.
# This file can be edited as more like, and can be copied into the 'wp-content/plugins/wp-w3all-custom/wpRoles_phpbbGroups.php' folder
# so that when the plugin will update, custom modifications will not be lost

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

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

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