XF 2.0 Adding a field to the xf_user table

AndyB

Well-known member
I added a field called most_likes_count to the xf_user table.

When I try to use this new field in a template like this:

1506994351274.webp

I get the following error:

1506993950521.webp

Do I need to extend the entity in order to use this new field in a template?
 
Yes I needed to extend the entit like this:

Listener.php
PHP:
<?php

namespace Andy\MostLikes\XF\Entity;

use XF\Mvc\Entity\Entity;

class Listener
{
    public static function userEntityStructure(\XF\Mvc\Entity\Manager $em, \XF\Mvc\Entity\Structure &$structure)
    {
        $structure->columns['most_likes_count'] = ['type' => Entity::UINT, 'default' => 0];
    } 
}

Code event listener:

1506997184100.webp

Now I get this error:
 
Last edited:
Back
Top Bottom