Avatars via phpBB group Avatar
Posted: Mon May 08, 2017 6:50 am
Hi, let me first say pretty solid plugin you have written, so thanks for the work on it!
Now to the issue...
May 7th, 2017 - WP_w3all Version 1.7.0
On my phpBB forums I am using "Group Avatars" when users have not set their own avatar
(via phpBB ACP --> Users & Groups --> Groups/Manage Groups: {Group Avatar})
WP_w3all provides a widget on WordPress to login, as well as show posts, etc. with the associated avatars.
This works when the phpBB user has uploaded their own image to the phpBB forum. This creates the avatar file that WP_w3all is fetching.
When a user has not uploaded their own avatar, but group avatars are set, WP_w3all tries to fetch the avatar for the user from a file pathway based on the user id, and not the phpBB logic in determining the avatar.
By going to to broken image URL you get a phpBB forum error page with:
The issue is with the definition being used in the WP plugin on lines 1347-1351 of /wp-w3all-phpbb-integration/class.wp.w3all-phpbb.php file
THE SOLUTION
In /wp-w3all-phpbb-integration/class.wp.w3all-phpbb.php
Old line 1349:
Replaced line with:
For group-set avatars, the $avatar_entry takes the form like "g10_0000HASHEDKEY0000.png", note that the entry starts with a 'g' character. Using strtok($avatar_entry,'_') the avatar id before '_' is returned in full as a string, which in this case would be 'g10' that is then used to get the correct image location. The old code using intval would produce a '0' and give an incorrect image location.
If you needed a group avatar fix for WP_w3all fix, I hope this helps you as well!
Now to the issue...
May 7th, 2017 - WP_w3all Version 1.7.0
- With phpBB group avatars set on the forums, on wordpress the WP_w3all plugin show a broken link for users with no personal avatar uploaded
On my phpBB forums I am using "Group Avatars" when users have not set their own avatar
(via phpBB ACP --> Users & Groups --> Groups/Manage Groups: {Group Avatar})
WP_w3all provides a widget on WordPress to login, as well as show posts, etc. with the associated avatars.
This works when the phpBB user has uploaded their own image to the phpBB forum. This creates the avatar file that WP_w3all is fetching.
When a user has not uploaded their own avatar, but group avatars are set, WP_w3all tries to fetch the avatar for the user from a file pathway based on the user id, and not the phpBB logic in determining the avatar.
By going to to broken image URL you get a phpBB forum error page with:
No route found for "GET /images/avatars/upload/<some userID>_0.png" (from "http://<URL of requesting page with broken image>")
The issue is with the definition being used in the WP plugin on lines 1347-1351 of /wp-w3all-phpbb-integration/class.wp.w3all-phpbb.php file
Code: Select all
$avatar_entry = $user_ava->user_avatar;
$ext = substr(strrchr($avatar_entry, '.'), 1);
$avatar_entry = intval($avatar_entry);
$phpbb_avatar_filename = $phpbb_config["avatar_salt"] . '_' . $avatar_entry . '.' . $ext;
$phpbb_avatar_url = get_option( 'w3all_url_to_cms' ).'/'.$phpbb_config["avatar_path"].'/'.$phpbb_avatar_filename;
THE SOLUTION
In /wp-w3all-phpbb-integration/class.wp.w3all-phpbb.php
Old line 1349:
Code: Select all
$avatar_entry = intval($avatar_entry);
Code: Select all
$avatar_entry = strtok($avatar_entry, '_');
For group-set avatars, the $avatar_entry takes the form like "g10_0000HASHEDKEY0000.png", note that the entry starts with a 'g' character. Using strtok($avatar_entry,'_') the avatar id before '_' is returned in full as a string, which in this case would be 'g10' that is then used to get the correct image location. The old code using intval would produce a '0' and give an incorrect image location.
If you needed a group avatar fix for WP_w3all fix, I hope this helps you as well!