It used to work lol"getIdentities" does not exist as a function in XenForo_Model or XenForo_Model_User.
What are you trying to do?
$hookParams['user']['user_id']
Ah yes sorry Chris I am trying to get the users custom field (I need to get some kip I think or more coffee)Do you not already have the user ID?
Or are you after the full user record?PHP:$hookParams['user']['user_id']
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.
$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();
}
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.
$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.Think you're looking for
PHP:$userModel = XenForo_Model::create('XenForo_Model_User'); $identities = $userModel->getFullUserById($hookParams['user']['user_id']);
<?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;
}
}
}
}
{$user.customFields.twitter}
Wow oh wow that was SOO much easier lol thanks everyone.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}
We use essential cookies to make this site work, and optional cookies to enhance your experience.