WP_w3all phpBB wordpress: not linked users mode or (still not) not added phpBB user in WP and avatars problem

Developing and fixes
User avatar
axew3
w3all User
w3all User
Posts: 2883
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Contact:

WP_w3all phpBB wordpress: not linked users mode or (still not) not added phpBB user in WP and avatars problem

Post by axew3 »

On integration plugin WP_w3all phpBB WordPress, at date of this post, the code do not return correct avatars results, if the user that the avatar need to be retrieved for, isn't already also registered member in WordPress, or the plugin run as "No linked users".

To resolve this issue, on file:
/wp-content/plugins/wp-w3all-phpbb-integration/class.wp.w3all-phpbb.php
function:

Code: Select all

wp_w3all_assoc_phpbb_wp_users()
there is this code:

Code: Select all

if($usid):
      	$wp_user_phpbb_avatar[] = array("wpuid" => $usid->ID, "phpbbavaurl" => $ava_set_x['uavaurl'], "phpbbuid" => 0);
      endif;
that lead to fill the array, but only if it is a wp user, and will not be possible to check against nothing to assign after the avatar for a specific post.
Then this may need to be changed into:

Code: Select all

	if($usid):
      	$wp_user_phpbb_avatar[] = array("wpuid" => $usid->ID, "phpbbavaurl" => $ava_set_x['uavaurl'], "phpbbuid" => 0);
      else:
      	$wp_user_phpbb_avatar[] = array("wpuid" => 0, "phpbbavaurl" => $ava_set_x['uavaurl'], "phpbbuid" => $ava_set_x['puid']);
      endif;
Then on /wp-content/plugins/wp-w3all-phpbb-integration/views/phpbb_last_topics.php for example
(so these changes needs to be applied on each views/ folder files that display shortcodes etc )
where:

Code: Select all

if(!empty($last_topics)){
immediately after, this should be added:

Code: Select all

// added	
$w3phpbbuava = unserialize(W3ALLPHPBBUAVA);
and where:

Code: Select all

$countn = 0;
foreach ($last_topics as $key => $value) {
immediately after add:

Code: Select all

// added 
if(!empty($w3phpbbuava)){
	foreach($w3phpbbuava as $k){
		if($k['phpbbuid'] == $value->user_id && $k['phpbbuid'] > 1){
			$phpbbUAVA = $k['phpbbavaurl'];
		}
  }
}
then where:

Code: Select all

   if( ! $wpu ){
			$w3all_avatar_display = get_avatar(0, $w3all_last_t_avatar_dim);
		} else {
     	      $w3all_avatar_display = get_avatar($wpu->ID, $w3all_last_t_avatar_dim);
          }
  } 
should be changed in:

Code: Select all

   if( ! $wpu && isset($phpbbUAVA) ){
             $w3all_avatar_display = ( is_email( $phpbbUAVA ) !== false ) ? get_avatar($phpbbUAVA, $w3all_last_t_avatar_dim) : '<img alt="" src="'.$phpbbUAVA.'" class="avatar" width="'.$w3all_last_t_avatar_dim.'" height="'.$w3all_last_t_avatar_dim.'">';
		} elseif ( ! $wpu && !isset($phpbbUAVA) ) {
     	      $w3all_avatar_display = get_avatar(0, $w3all_last_t_avatar_dim);
          } else {
     	      $w3all_avatar_display = get_avatar($wpu->ID, $w3all_last_t_avatar_dim);
          }
  } 
result_ava1.png
result_ava1.png (26.32 KiB) Viewed 17873 times
If nothing wrong should work on any situation now but i've still not test on all configuration, so appreciated any possible report.
User avatar
axew3
w3all User
w3all User
Posts: 2883
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Contact:

Re: WP_w3all phpBB wordpress: not linked users mode or (still not) not added phpBB user in WP and avatars problem

Post by axew3 »

the above will be now patched, because the code was failing if the user had a gravatar instead then an url,
THEN the above code for:
/wp-content/plugins/wp-w3all-phpbb-integration/views/phpbb_last_topics.php
where this line:

Code: Select all

$w3all_avatar_display = '<img alt="" src="'.$phpbbUAVA.'" class="avatar" width="'.$w3all_last_t_avatar_dim.'" height="'.$w3all_last_t_avatar_dim.'">';
has been changed into:

Code: Select all

$w3all_avatar_display = ( is_email( $phpbbUAVA ) !== false ) ? get_avatar($phpbbUAVA, $w3all_last_t_avatar_dim) : '<img alt="" src="'.$phpbbUAVA.'" class="avatar" width="'.$w3all_last_t_avatar_dim.'" height="'.$w3all_last_t_avatar_dim.'">';
now seem to work as expected in any case.
Post Reply