get_avatar() not work
-
I have custom apps need to get wordpress user data. Here is the code:
public function authUser(ConnectionInterface $conn, array $cookies) { global $current_user; $current_user = null; $wpDir = $conn->Config['wordpress']['dir']; $this->debug("WP Autorization cookies:"); $this->debug($cookies); foreach ($cookies as $key => $value) { $_COOKIE[$key] = urldecode($value); } require_once($wpDir . '/wp-config.php'); require_once($wpDir . '/wp-includes/wp-db.php'); require_once($wpDir . '/wp-includes/pluggable.php'); $userInfo = wp_get_current_user(); if(!$userInfo || !$userInfo->ID){ return null; } // get avatar from WordPress $avatar = get_avatar( $userInfo->ID, 50 ); return array( 'id' => $userInfo->ID, 'name' => $userInfo->display_name, 'image' => $avatar ); }
‘id’ and ‘name’ is working good… I got the ID and display name. But the ‘image’ is not work getting avatar image. Is there anything I missed here? Any help and suggestion really appreciated. Thank you.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘get_avatar() not work’ is closed to new replies.