Right. Mixing up my vbulletin terminology. Hrm, editing files when updating is never fun, but if that's the only way...Hooks are for templates and besides it is now better to use a template modification for that.
As far as I know you cannot extend the _getDefaultAvatarUrl() function as it is a static one. I do believe you will have to actually edit it.
<span class="avatarContainer">
<a href="index.php?members/admin.1/" class="avatar Av1s" data-avatarhtml="true"><img src="styles/default/xenforo/avatars/avatar_s.png" width="48" height="48" alt="Admin"></a>
<a href="index.php?members/admin.1/" class="avatar Av1s miniMe" title="You have posted 1 message(s) in this thread" data-avatarhtml="true"><img src="styles/default/xenforo/avatars/avatar_other_s.png" width="48" height="48" alt="Admin"></a>
</span>
if (!isset($user['customFields']['gender']))
{
$user['customFields']['gender'] = '';
}
switch ($user['customFields']['gender'])
{
case 'field1':
case 'field2':
case 'field3':
$gender = $user['customFields']['gender'] . '_';
break;
default:
$gender = '';
break;
}
if (!$imagePath = self::styleProperty('imagePath'))
{
$imagePath = 'styles/default';
}
if (!isset($user['customFields']['gender']))
{
$user = self::_getModelFromCache('XenForo_Model_User')->getFullUserById($user['user_id']);
$user['customFields'] = (!empty($user['custom_fields']) ? @unserialize($user['custom_fields']) : array());
}
$gender = '';
$customFields = $user['customFields'];
if (key_exists('gender', $customFields))
$gender = strtolower($customFields['gender']) . '_';
return "{$imagePath}/xenforo/avatars/avatar_{$gender}{$size}.png";
protected static function _getDefaultAvatarUrl(array $user, $size)
{
if (!isset($user['gender']))
{
$user['gender'] = '';
}
switch ($user['gender'])
{
case 'male':
case 'female':
$gender = $user['gender'] . '_';
break;
default:
$gender = '';
break;
}
if (!$imagePath = self::styleProperty('imagePath'))
{
$imagePath = 'styles/default';
}
//added
if (!isset($user['customFields']['gender']))
{
$user = self::_getModelFromCache('XenForo_Model_User')->getFullUserById($user['user_id']);
$user['customFields'] = (!empty($user['custom_fields']) ? @unserialize($user['custom_fields']) : array());
}
$gender = '';
$customFields = $user['customFields'];
if (key_exists('gender', $customFields))
$gender = strtolower($customFields['gender']) . '_';
//end added
return "{$imagePath}/xenforo/avatars/avatar_{$gender}{$size}.png";
}
actually in this case it is mandatory and other is just one of the choices.If the custom field is not mandatory then perhaps you need to have the default avatar and thus gender as 'other'?
$gender = 'other_';
and then change it only if the field is set?!
We use essential cookies to make this site work, and optional cookies to enhance your experience.