Add Gravatar image to Accounts page in Opencart

Age of Article Warning:
This article was originally published 66 months ago. The information, tips and techniques explained may outdated. Examples shown on this page may no longer work. Please consider this when viewing the below content.

add gravatar to opencart account page

 
Recently I had an enquiry on how to add a customer’s Gravatar image to their Account page in Opencart. With a little bit of research I found out that you can “get” the following customer details:

    $this->customer->isLogged()
    $this->customer->getId()
    $this->customer->getFirstName()
    $this->customer->getLastName()
    $this->customer->getEmail()
    $this->customer->getTelephone()
    $this->customer->getFax()
    $this->customer->getNewsletter()
    $this->customer->getCustomerGroupId()
    $this->customer->getAddressId()
    $this->customer->getBalance()
    $this->customer->getRewardsPoints()

So we can use “getEmail” to extract the email address, and we then simply add the code into the account.tpl file to complete the Gravatar url as shown below, which will then display the Gravatar image.

<img src="http://www.gravatar.com/avatar/<?php echo md5(strtolower(trim($this->customer->getEmail()))); ?>" />

So if your client is using their Gravatar email address as their account email address, then their accompanying image will be displayed, otherwise a default Gravatar image will be shown.

For those who prefer to use VQMOD, I’ve put together a VQMOD XML file that is available as a download below. Simply unzip the file and upload the dtwdshowgravataraccountpage.xml file to your vqmod > vqcache folder. [wdsm_ad id=”1487″ class=” ” ]

2 thoughts on “Add Gravatar image to Accounts page in Opencart

Comments are closed.