I haven't created a Magento module before and after a lot of research I attempted to create a module to insert wordpress avatars into blog posts inside Magento (I am using Fishpig).

Below I will list my folder structure and what I have in my files but I can't seem to get my custom module to work!

JUST TO NOTE: I am trying to extend "Fishpig_Wordpress_Model_User"

app/code/local/Splitpixel/Avatar/Fishpig/Wordpress/Model/User.php app/code/local/Splitpixel/Avatar/etc/config.xml


My Splitpixel_Avatar.xml:

<?xml version="1.0" encoding="UTF-8"?>

            <!-- Whether our module is active: true or false -->

            <!-- Which code pool to use: core, community or local -->


My config.xml:

> <?xml version="1.0" encoding="UTF-8"?> <config>
>     <modules>
>         <Splitpixel_Avatar>
>             <version>0.0.1</version>
>         </Splitpixel_Avatar>
>     </modules>
>     <global>
>         <models>
>             <fishpig>
>                     <wordpress>
>                             <rewrite>
>                                 <user>Splitpixel_Avatar_Fishpig_Wordpress_Model_User</user>
>                             </rewrite>
>                     </wordpress>
>             </fishpig>
>         </models>
>     </global> </config>

My app/code/local/Splitpixel/Avatar/Fishpig/Wordpress/Model/User.php:

> <?php 
> class Splitpixel_Avatar_Fishpig_Wordpress_Model_User extends
> Fishpig_Wordpress_Model_User {
>     public function getUserAvatar(){
>         $imageSource = “”;
>         $avatarPostId = $this->getMetaValue(‘wp_user_avatar’);
>         $collection = Mage::getResourceModel(‘wordpress/post_collection’)->addPostTypeFilter(‘attachment’)->addFieldToFilter(‘ID’, $avatarPostId);
>         foreach($collection as $post){
>             if ($post->getId() == $avatarPostId){
>                 $imageSource =  $post->getData(‘guid’);
>                 return $imageSource;
>             }
>         }
>         return $imageSource;
>     } }
> ?>

And then finally I am trying to use the new function in "template/wordpress/post/meta.phtml" by using the following code:

> $post->getAuthor()->getDisplayName()
> $post->getAuthor()->getUserAvatar()

The code pulls back nothing! Now it may be my code, but the most likely factor is that I have dome something wrong in my config.xml or folder sructure as this is all new to me!

Any help is REALLY appreciated, thanks!

EDIT: Posted same time as patch drop so got missed by most!

1 Answer 1


Usually when extending module classes I trail the extension of a parent method for example _construct() - As far as extending User.php I can confirm the below works;


<?xml version="1.0"?>
                <Fishpig_Wordpress />


class Splitpixel_Avatar_Model_User extends Fishpig_Wordpress_Model_User

    public function _construct()
        return parent::_construct();



<?xml version="1.0"?>

With regards to your function to get the avatar URL, I'm a little confused as to why you're not using the functionality provided within the module already, for example;

  • getGravatarUrl()
  • getUserPhoto() - "The UserPhoto plugin must be installed in WordPress"
  • Hi thanks for the help! I added that code to my user.php and it gave me a server error, is this correct? Just to test whether the module is extending the class? Unfortunately my code to echo the avater errors the whole page out so need to figure that out! Nov 5, 2015 at 13:11
  • @KiwisTasteGood Sorry to hear you've got a server error, I've updated my reply to include a tested rewrite.
    – Dan Norris
    Nov 6, 2015 at 9:54
  • Hi again, I could not find the getUserPhoto() anywhere when researching this but it works perfectly! Thank you :) Nov 9, 2015 at 14:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.