avatar issue | WordPress.org

[ad_1]

Hello Ali.

Could you change a few lines of code in the JSON_API_User_Controller class where it concerns avatars.

When calling the get_userinfo(), generate_auth_cookie(), get_currentuserinfo() methods in the array, the $avatar[1] variable is returned.

We do not use these avatars in our application. These avatars cause an error:

[error][ErrorException:8] ErrorException: Undefined offset: 1 in C:\wordpress\wp-content\plugins\json-api-user\controllers\User.php:467

I suggest changing this code like this:

"avatar" => isset($avatar[1]) ? $avatar[1] : NULL,

or
"avatar" => $avatar[1] ?? NULL,
or
$avatar[1] = NULL;

preg_match('|src="https://projectdmc.org/support/topic/avatar-issue-9/(.+?)"|', get_avatar( $user->ID, 32 ), $avatar);

return array(
“cookie” => $cookie,
“cookie_admin” => $cookie_admin,
“cookie_name” => LOGGED_IN_COOKIE,
“user” => array(
“id” => $user->ID,
“username” => $user->user_login,
“nicename” => $user->user_nicename,
“email” => $user->user_email,
“url” => $user->user_url,
“registered” => $user->user_registered,
“displayname” => $user->display_name,
“firstname” => $user->user_firstname,
“lastname” => $user->last_name,
“nickname” => $user->nickname,
“description” => $user->user_description,
“capabilities” => $user->wp_capabilities,
“avatar” => ==> See Above <===
);

Thank you for your attention!

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer