From 55837a9bf40ce070d74031043d1c8dab274df1a2 Mon Sep 17 00:00:00 2001 From: arifulhoque7 Date: Thu, 18 Sep 2025 12:13:02 +0600 Subject: [PATCH 1/3] fix: profile photo priority higher than avatar fields --- wpuf-functions.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/wpuf-functions.php b/wpuf-functions.php index 3987eaf4e..b308b559e 100644 --- a/wpuf-functions.php +++ b/wpuf-functions.php @@ -673,6 +673,20 @@ function wpuf_avatar_add_image_size() { * @return string */ function wpuf_get_custom_avatar( $user_id ) { + // First check for profile photo (higher priority) + $profile_photo = get_user_meta( $user_id, 'wpuf_profile_photo', true ); + + if ( absint( $profile_photo ) > 0 ) { + wpuf_avatar_add_image_size(); + + $avatar_source = wp_get_attachment_image_src( $profile_photo, 'wpuf_avatar_image_size' ); + + if ( $avatar_source ) { + return $avatar_source[0]; + } + } + + // Fall back to user avatar if no profile photo $avatar = get_user_meta( $user_id, 'user_avatar', true ); if ( absint( $avatar ) > 0 ) { From e470cefbc5f25616d028732da49fa4777ab3fa41 Mon Sep 17 00:00:00 2001 From: arifulhoque7 Date: Fri, 19 Sep 2025 15:07:34 +0600 Subject: [PATCH 2/3] fix: handles cases where wp_get_attachment_im age_src() returns false or an incomplete array structure --- wpuf-functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wpuf-functions.php b/wpuf-functions.php index b308b559e..862802817 100644 --- a/wpuf-functions.php +++ b/wpuf-functions.php @@ -681,7 +681,7 @@ function wpuf_get_custom_avatar( $user_id ) { $avatar_source = wp_get_attachment_image_src( $profile_photo, 'wpuf_avatar_image_size' ); - if ( $avatar_source ) { + if ( $avatar_source && is_array( $avatar_source ) && isset( $avatar_source[0] ) ) { return $avatar_source[0]; } } @@ -694,7 +694,7 @@ function wpuf_get_custom_avatar( $user_id ) { $avatar_source = wp_get_attachment_image_src( $avatar, 'wpuf_avatar_image_size' ); - if ( $avatar_source ) { + if ( $avatar_source && is_array( $avatar_source ) && isset( $avatar_source[0] ) ) { $avatar = $avatar_source[0]; } } From 404c11aed9768d7a36864a0859acbb0c5fe1e97f Mon Sep 17 00:00:00 2001 From: arifulhoque7 Date: Mon, 22 Sep 2025 15:38:36 +0600 Subject: [PATCH 3/3] chore : change isset to not empty --- wpuf-functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wpuf-functions.php b/wpuf-functions.php index 862802817..a69222085 100644 --- a/wpuf-functions.php +++ b/wpuf-functions.php @@ -681,7 +681,7 @@ function wpuf_get_custom_avatar( $user_id ) { $avatar_source = wp_get_attachment_image_src( $profile_photo, 'wpuf_avatar_image_size' ); - if ( $avatar_source && is_array( $avatar_source ) && isset( $avatar_source[0] ) ) { + if ( $avatar_source && is_array( $avatar_source ) && ! empty( $avatar_source[0] ) ) { return $avatar_source[0]; } } @@ -694,7 +694,7 @@ function wpuf_get_custom_avatar( $user_id ) { $avatar_source = wp_get_attachment_image_src( $avatar, 'wpuf_avatar_image_size' ); - if ( $avatar_source && is_array( $avatar_source ) && isset( $avatar_source[0] ) ) { + if ( $avatar_source && is_array( $avatar_source ) && ! empty( $avatar_source[0] ) ) { $avatar = $avatar_source[0]; } }