If i have understand what you mean (sorry). I will maybe completely understand the best (to me) how to going on here.
Code: Select all
private static function verify_phpbb_credentials(){
himself, do not waste too much and essentially works with a single query to phpBB practically 98% of the times.
As basic, and without activating (and even if) pm options etc, it is very fast. Surely it could be needed into a site with a really but really high traffic, but sure it is required in your case?
If yes, and if anyway you want.
First thoughts:
Ok, it can be assuming so, that in phpBB, users cannot update their data about email and password?
Because there will not be updated data about the user, if user's data changed into phpBB in the while, if not using the phpBB extension.
So you'll maybe use it?
Having a remember me cookie always set, maybe yes, it is ok, or the user navigating from phpBB to wp and viceversa could result to be logged in into one and not into another, because in the while that the user navigate the WP side, the phpBB session is not updated.
Or the query could be reduced to get the phpBB userID, the user Group and then update the session, that's what it do normally, adding some data more
Code: Select all
// remember me auto login
$phpbb_user_session = $w3all_phpbb_connection->get_results("SELECT *
FROM ". $w3all_config["table_prefix"] ."sessions_keys
JOIN ". $w3all_config["table_prefix"] ."users ON ". $w3all_config["table_prefix"] ."users.user_id = ".$w3all_config["table_prefix"] ."sessions_keys.user_id
AND ". $w3all_config["table_prefix"] ."sessions_keys.key_id = '".md5($phpbb_k)."'
AND ". $w3all_config["table_prefix"] ."users.user_id = ". $phpbb_u ."
JOIN ". $w3all_config["table_prefix"] ."groups ON ". $w3all_config["table_prefix"] ."groups.group_id = ". $w3all_config["table_prefix"] ."users.group_id
LEFT JOIN ". $w3all_config["table_prefix"] ."profile_fields_data ON ". $w3all_config["table_prefix"] ."profile_fields_data.user_id = ". $phpbb_u ."
LEFT JOIN ". $w3all_config["table_prefix"] ."banlist ON ". $w3all_config["table_prefix"] ."banlist.ban_userid = ". $phpbb_u ." AND ban_exclude = 0
GROUP BY ". $w3all_config["table_prefix"] ."sessions_keys.user_id");
About a function that should automatically switch the WP user to a specific WP role, based on the passed phpBB group.
So the function could provide also another param, the WP role where the user will be switched to, if we already know it at the time we go to call the function, that would be easier instead to have inside the function, an array of switches.
Maybe the third param could be both an array, so used for the switches, or a specific role, if we already know.
It depend where the code will be used.
So, which code will call this function?
Where you want to hook it? (can you please better explain this?)
Because if the switch need to happen due to a phpBB group change into phpBB, then you need to know the phpBB user's group, and the query of the verify_phpbb_credentials() can be yes reduced, but how it will gain in milliseconds? Anyway yes, it can be also faster removing data to be retrieved and not executing all the verify_phpbb_credentials().
Or, the function can be called from phpBB, so to be synchronous, calling it when an user change the group into phpBB?
The code could be easily added into the phpBB WordPress extension.
These are first thoughts at moment
ps i created lately a script for a site where something like this happen but with:
phpBB groups changes:
user's subscribed to specifics newsletters into Sendy service, and addition into specifics memberpress memberships, when via admin they go to move an user from a group to another.
An headache that finally worked very well.
So to say, that it can be maybe a function that can be called from phpBB and be synchronous.
Let figure out how all could work in code, a function that can be called to accomplish with these tasks, passing to it the mentioned params.
Do you mean this? A function that can be called from phpBB?
If the call is internal, fired by some WP event, the code little change: it will provide a working function that will maybe accomplish with any scenario
Code: Select all
function w3all_wp_phpbb_user_groupSwitch_phpbb_wp( $u_name_email_id = '', $phpGroupId = '', $switchGroupsVals = '' ) {
[EDITED]