Usermodel question

x4rl

Well-known member
Any idea why this is not working?

Code:
                $userModel = XenForo_Model::create('XenForo_Model_User');
                $identities = $userModel->getIdentities($hookParams['user']['user_id']);

Keep getting

Code:
undefined method XenForo_Model_User::getIdentities()
 
"getIdentities" does not exist as a function in XenForo_Model or XenForo_Model_User.

What are you trying to do?
 
"getIdentities" does not exist as a function in XenForo_Model or XenForo_Model_User.

What are you trying to do?
It used to work lol
I'm just trying to pull the user ID. How do you find all the functions Chris? what would be the best way?
 
Do you not already have the user ID?
PHP:
$hookParams['user']['user_id']
Or are you after the full user record?

You can get the user's details using the getUserByUserId function in the user model.

I believe the getIdentities function was previously used to get a user's contact details. This has moved to custom fields that's why the getIdentities function no longer works.
 
Do you not already have the user ID?
PHP:
$hookParams['user']['user_id']
Or are you after the full user record?

You can get the user's details using the getUserByUserId function in the user model.

I believe the getIdentities function was previously used to get a user's contact details. This has moved to custom fields that's why the getIdentities function no longer works.
Ah yes sorry Chris I am trying to get the users custom field (I need to get some kip I think or more coffee)

This is what I used to use.
Code:
$userModel = XenForo_Model::create('XenForo_Model_User');
                $identities = $userModel->getIdentities($hookParams['user']['user_id']);

                if (!empty($identities['twitter'])) {
                    $twitterId = $identities['twitter'];
                    $ourTemplate = $template->create('xen_profile_twitter_main');
                    $ourTemplate->setParam('twitter', $twitterId);
                    $contents .= $ourTemplate->render();
                }
 
Last edited:
Chris would it be this than?

Code:
                $userModel = XenForo_Model::create('XenForo_Model_User');
                $identities = $userModel->getUserIdFromUser($hookParams['user']['user_id']);

It gives no errors but also nothing shows.
 
Chris would it be this than?

Code:
                $userModel = XenForo_Model::create('XenForo_Model_User');
                $identities = $userModel->getUserIdFromUser($hookParams['user']['user_id']);

It gives no errors but also nothing shows.

Think you're looking for

PHP:
$userModel = XenForo_Model::create('XenForo_Model_User');
$identities = $userModel->getFullUserById($hookParams['user']['user_id']);
 
Think you're looking for

PHP:
$userModel = XenForo_Model::create('XenForo_Model_User');
$identities = $userModel->getFullUserById($hookParams['user']['user_id']);
I still can't seem to get it to work tho.

PHP:
<?php

class Wuebit_Model_index
{
    public static function templateHook($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template)
    {
        switch ($hookName)
        {
            case 'member_view_sidebar_middle2':
            {
                $userModel = XenForo_Model::create('XenForo_Model_User');
                $identities = $userModel->getFullUserById($hookParams['user']['user_id']);

                if (!empty($identities['twitter'])) {
                    $twitterId = $identities['twitter'];
                    $ourTemplate = $template->create('Wuebit_Twitter_Profile_Main');
                    $ourTemplate->setParam('twitter', $twitterId);
                    $contents .= $ourTemplate->render();
                }
                break;
            }
        }
    }
}

It seem's not to add the template on that hook.
 
Sorry it too me so long to respond.

I think you ought to start again from scratch.

There's a heck of a lot of new stuff in XenForo 1.2.

One such thing is Template Modifications which basically enable you to specify a template, find some code within it, and replace it with your own code. It's much easier and much more flexible. Template hooks are officially deprecated. And although technically they should still work, they aren't as favourable as the Template Modification system.

Also, as the contact information is now stored in custom fields, you don't even need any custom PHP to fetch them.

Once you've added your template code using a template modification, you can get the value of a user's Twitter account using:

Code:
{$user.customFields.twitter}
 
Sorry it too me so long to respond.

I think you ought to start again from scratch.

There's a heck of a lot of new stuff in XenForo 1.2.

One such thing is Template Modifications which basically enable you to specify a template, find some code within it, and replace it with your own code. It's much easier and much more flexible. Template hooks are officially deprecated. And although technically they should still work, they aren't as favourable as the Template Modification system.

Also, as the contact information is now stored in custom fields, you don't even need any custom PHP to fetch them.

Once you've added your template code using a template modification, you can get the value of a user's Twitter account using:

Code:
{$user.customFields.twitter}
Wow oh wow that was SOO much easier lol thanks everyone.
 
Top Bottom