XF 2.1 How to create and fetch a custom field in the xf_user table?

asprin

Active member
I'm looking to add a new "int" column to the xf_user table. I tried adding it directly via phpmyadmin but then when I use the following code (in an external application but hosted on the same server), it isn't getting listed in the fetched columns
PHP:
XF::start($dir);
$app = XF::setupApp('XF\Pub\App');
$session = $app->session();

$uid = $session->get('userId');
if ($uid)
{          
    $finder = \XF::finder('XF:User');
    $user = $finder->where('user_id', $uid)->fetchOne()->toArray();            
    print_r($user); // this doesn't show the vcash column but shows other out-of-the-box fields
}

xf_user table
1578410787624.png


I'm not entirely sure what the exact approach is since I'm very new to Xenforo and have not much idea about the Administration part.



UPDATE:
After some research, I tried using the Administration section and adding the custom field there also.
1578410979380.webp

But even after doing this, I wasn't able to fetch the column value via the $finder method. Also, the same field isn't visible in the profile section as well. I've not added any add-ons. It's a fresh out-of-the-box template.
 
Top Bottom