Title: get_avatar_url() with https
Last modified: January 20, 2020

---

# get_avatar_url() with https

 *  Resolved [metalhead505](https://wordpress.org/support/users/metalhead505/)
 * (@metalhead505)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/get_avatar_url-with-https/)
 * Hello,
 * I’m using get_avatar_url() to return user avatar url, but it returns it as http
   instead of https. My desired result is to have it return the url as https.
 * This is what I’ve tried:
 *     ```
       $user = wp_get_current_user();
       $args = array('scheme' => 'https'); 
       $chat_picture_url = get_avatar_url($user->ID, $args);
       ```
   
 * However, the url is still being returned as http.
 * Is there anything wrong with my code that would cause it to fail? I don’t have
   any logged php errors.
 * Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [autotutorial](https://wordpress.org/support/users/autotutorial/)
 * (@autotutorial)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/get_avatar_url-with-https/#post-12342642)
 * the set_url_scheme is used [https://developer.wordpress.org/reference/functions/get_avatar_data/](https://developer.wordpress.org/reference/functions/get_avatar_data/)(
   reference for get_avatar_url )
    For default url read line 4226 for link [https://developer.wordpress.org/reference/functions/set_url_scheme/](https://developer.wordpress.org/reference/functions/set_url_scheme/)(
   force it’s with $args[‘url’] or use wp_redirect)
 *     ```
       if ( is_ssl() ) {
               $url = 'https://secure.gravatar.com/avatar/' . $email_hash;
           } else {
               $url = sprintf( 'http://%d.gravatar.com/avatar/%s', $gravatar_server, $email_hash );
           }
       ```
   
 * [https://developer.wordpress.org/reference/functions/wp_redirect/](https://developer.wordpress.org/reference/functions/wp_redirect/)
 *  Thread Starter [metalhead505](https://wordpress.org/support/users/metalhead505/)
 * (@metalhead505)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/get_avatar_url-with-https/#post-12345077)
 * I didn’t see that coming.
 * Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘get_avatar_url() with https’ is closed to new replies.

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 2 replies
 * 2 participants
 * Last reply from: [metalhead505](https://wordpress.org/support/users/metalhead505/)
 * Last activity: [6 years, 4 months ago](https://wordpress.org/support/topic/get_avatar_url-with-https/#post-12345077)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
