XF 2.0 Accessed unknown getter 'column_name' on XF:User[3] (src\XF\Mvc\Entity\Entity.php:178)

logixsol

Member
I have created a column in xf_user table, Now its showing when i dump the user object in template. But unable to use it.
Getting the below attached error.

Please also check the template errors.
 

Attachments

  • xxx.webp
    xxx.webp
    114.6 KB · Views: 99
Last edited:
The column has to be defined in the Entity as well.
I'm experiencing the same issue, and I'm afraid I'm not sure what your response here means. Could you clarify what else I need to do to have an additional column work with $xf.visitor ?
 
You need to extend \XF\Entity\User and add your column to the structure (scroll down a bit, you won't miss it).
 
You need to extend \XF\Entity\User and add your column to the structure (scroll down a bit, you won't miss it).
I just got into that file - thanks!
I know I should "extend" this and not just edit the default Xenforo file, is there easy to follow documentation on best practices there? Otherwise, the temptation to just edit the file itself will be very great...
 
Call the parent function and extend the structure returned from the parent:
PHP:
    public static function getStructure(Structure $structure)
    {
        $parent = parent::getStructure($structure);
        $parent->columns['your_column'] = ['type' => the_type, 'foo' => bar, 'etc' => pp];
        return $parent;
    }
 
Top Bottom