Add-on Global Variable

Itworx4me

Well-known member
I am in need of an add-on that will make this variable global $user.customFields.x. Willing to pay if not too extreme...lol

Thanks,
Itworx4me
 
Last edited:
What is $user? Where is the variable coming from?

If you mean the current user (aka $visitor:D ) you can already access it via

{$visitor.customFields.X}


http://xenforo.com/help/custom-user-fields/
@xf_phantom I tired your suggestion and it didn't work.

I have a custom user field that my users fill out. I am trying to call that custom field in many templates. Currently it doesn't work in thread_list_item. The only place I have been able to get the variable to work is message_user_info ({$user.cusomField.X}) Reason that I need the variable to be global for it to work in any template.

Thanks,
Itworx4me
 
I have been fighting this variable all day. I added the {xen:helper dump, $visitor} to the thread_list_item template. It tells me that the custom_fields variable is there to use. But when I try and use {$visitor.customFields.nick_name} it returns nothing. Can someone help me out on this one?

Thanks,
Itworx4me
 
And what happens if you use

Code:
{xen:helper userFieldValue, 'nick_name', $visitor, {$visitor.customFields.nick_name}}
 
@xf_phantom Here is my code:
Code:
<xen:if is="{$visitor.user_id}">
    <xen:username user="$thread" title="{xen:phrase thread_starter}" /><span class="startDate">,
<xen:else />
    <a href="/login/login" class="username" itemprop="name">{xen:helper userFieldValue, 'nick_name', $visitor, {$visitor.customFields.nick_name}}</a>
</xen:if>

The new code you had me try does nothing.....

Thanks,
Itworx4me
 
it won't work because guests don't have custom fields;)

Rich (BB code):
<xen:if is="{$visitor.user_id}">
<xen:username user="$thread" title="{xen:phrase thread_starter}" /><span class="startDate">,
<xen:else />
<a href="/login/login" class="username" itemprop="name">{xen:helper userFieldValue, 'nick_name', $visitor, {$visitor.customFields.nick_name}}</a>
</xen:if>

the red code will ONLY be shown to guests and because they DON'T have userFields, it won't work;)
 
@xf_phantom I would be happy to pay you (with in reason) to make an add-on that will make $user.customFields.X global. Then I can use it in any template....

Thanks,
Itworx4me
 
I don't understand, what you want to accomplish

You want to show the value of a userfield to guests?! (at least that's what your code from post 6 is trying to do)

But guests don't have userfields?!
 
this http://xenforo.com/community/threads/hide-username.63831/#post-675024 ?

then it should probably be
Code:
<xen:if is="{$visitor.user_id}">
<xen:username user="$thread" title="{xen:phrase thread_starter}" /><span class="startDate">,
<xen:else />
<a href="/login/login" class="username" itemprop="name">{xen:helper userFieldValue, 'nick_name', $user, {$user.customFields.nick_name}}</a>
</xen:if>
@xf_phantom
I get this error:
Template Errors: forum_view
  1. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/xxxx/public_html/library/XenForo/Template/Helper/Core.php, line 2150
  2. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/xxxx/public_html/library/XenForo/Template/Helper/Core.php, line 2150
  3. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/xxxx/public_html/library/XenForo/Template/Helper/Core.php, line 2150
  4. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/xxxx/public_html/library/XenForo/Template/Helper/Core.php, line 2150
  5. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/xxxx/public_html/library/XenForo/Template/Helper/Core.php, line 2150
  6. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/xxxx/public_html/library/XenForo/Template/Helper/Core.php, line 2150
  7. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/xxxx/public_html/library/XenForo/Template/Helper/Core.php, line 2150
  8. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/xxxx/public_html/library/XenForo/Template/Helper/Core.php, line 2150
  9. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/xxxx/public_html/library/XenForo/Template/Helper/Core.php, line 2150
  10. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/xxxx/public_html/library/XenForo/Template/Helper/Core.php, line 2150
  11. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/nitro/public_html/library/XenForo/Template/Helper/Core.php, line 2150
  12. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/xxxx/public_html/library/XenForo/Template/Helper/Core.php, line 2150
  13. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/xxxx/public_html/library/XenForo/Template/Helper/Core.php, line 2150
  14. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/xxxx/public_html/library/XenForo/Template/Helper/Core.php, line 2150
  15. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/xxxx/public_html/library/XenForo/Template/Helper/Core.php, line 2150
  16. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/nitro/public_html/library/XenForo/Template/Helper/Core.php, line 2150
  17. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/xxxx/public_html/library/XenForo/Template/Helper/Core.php, line 2150
  18. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/nitro/public_html/library/XenForo/Template/Helper/Core.php, line 2150
  19. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/xxxx/public_html/library/XenForo/Template/Helper/Core.php, line 2150
  20. Argument 2 passed to XenForo_Template_Helper_Core::helperUserFieldValue() must be an array, null given in /home/xxxx/public_html/library/XenForo/Template/Helper/Core.php, line 2150
Thanks,
Itworx4me
 
about what exactly are we talking?:D

I thought that you want to replace the message_user_info (2)
1234.webp

You should really try to explain it better:P
 
@xf_phantom

I am wanting to hide all usernames on my site and replace them with a custom field named Nick Name(user-id nick_name). I only want to show the nick name to registered and un-registered members. I have a usergroup Verified Members that I want to see peoples real name. So I am going through all the templates that deal with usernames and trying to replace them with the nick name. I need to be able to access the custom field from any template in xeforo. Hense why I am asking for it to be global...Sorry for not explaining it better.

Itworx4me
 
Top Bottom