I just finished and prepared yesterday night 2 different:
Code: Select all
function w3all_wp_phpbb_user_groupSwitch_phpbb_wp( $phpbb_u_list_ids_emails_phpbbGroups = '', $phpbbGroups_wpRoles_schema = '' ){
Code: Select all
function w3all_wp_phpbb_user_groupSwitch_wp_phpbb( $wp_u_list_ids_emails = '', $wp_u_list_ids_emails_and_roles = '', $wpRoles_phpbbGroups_schema = '' ){
phpBB to WP
the
Code: Select all
function w3all_wp_phpbb_user_groupSwitch_phpbb_wp( $phpbb_u_list_ids_emails_phpbbGroups = '', $phpbbGroups_wpRoles_schema = '' ){
The param $phpbbGroups_wpRoles_schema allow to have into this case, a predictable behavior that can be applied the same for any scenario.
In WordPress can be removed an user from the main role and assign a new one with easy.
I do not remember if there is a scenario where an user in WP can belong to more than one role.
If yes, the code can be easily modified to accomplish and fit any scenario.
And as it will be by default, it consider to remove the WP Role on key 0, substituting it with the new one, based on the passed schema.
If a schema param is not provided, it will be used the default one.
WP to phpBB
while the
Code: Select all
function w3all_wp_phpbb_user_groupSwitch_wp_phpbb( $wp_u_list_ids_emails = '', $wp_u_list_ids_emails_and_roles = '', $wpRoles_phpbbGroups_schema = '' ){
It is intended to be used into any hook or class within WP.
It accept into the first param the WP user ID(s) or email(s) (1 or more separated by comma), then it switch into phpBB the user's group so to be the corresponding one, based on the passed schema. If a schema will not be provided as param, the default one will be used.
The $wp_u_list_ids_emails_and_roles = '', param is not used at all at moment, but result to be useful to be implemented in certain circumstances, where to make it lighter the function work, if we know at the time that we call the function, not only the user's email or ID, but also the value of his actual WP user Role, we can pass it together with the userID or email. But will be not mandatory nor default, just a plus.