Allowing custom field for specific usergroup

Will

Active member
I want to allow a specific usergroup to be able to see a custom profile field. I know it is not possible without customizing some code so any help would be appreciated.
 
It shows... for every usergroup. I wanted it to show for only this listed: {xen:helper ismemberof, $visitor, 3, 7, 17, 4}

I'm not following what you are saying above. That code will work by itself. I had it like that to begin with. Then Jake helped with the "array" part. Now, when I go to add that same thing back, and include the next <xen: if is> and </xen:if>, both won't work together.

Try this

Code:
<xen:foreach loop="$customFields" value="$field">
    <xen:if is="{$field.isEditable}">
        <xen:if is="{$field.field_id} != 'YouTube' OR {xen:helper ismemberof, $visitor, 3, 7, 17, 4}">
            <xen:if is="!in_array({$field.field_id}, array('pano', 'mixpod', 'mixpodautoplay', 'mixpodplaylistlink', 'mixpodcolor1', 'mixpodcolor2', 'mixpodcolor3')) OR {xen:helper ismemberof, $visitor, 3, 17, 4}">
                <xen:include template="custom_field_edit" />
            </xen:if>
        </xen:if>
  </xen:if>
</xen:foreach>
 
This was my Server Error Log:
Code:
Stack Trace
 
#0 /home/derek/public_html/library/TMS/Template/Compiler.php(61): XenForo_Template_Compiler->lexAndParse()
#1 /home/derek/public_html/library/TMS/Model/Template.php(54): TMS_Template_Compiler->modifyAndParse('custom_fields_e...', 18, 2192)
#2 /home/derek/public_html/library/TMS/Model/Template.php(177): TMS_Model_Template->getEffectiveTemplateByTitle('custom_fields_e...', 18)
#3 /home/derek/public_html/library/XenForo/Model/Template.php(1014): TMS_Model_Template->compileAndInsertParsedTemplate(4325, Array, 'custom_fields_e...', 18)
#4 /home/derek/public_html/library/XenForo/Model/Template.php(986): XenForo_Model_Template->compileTemplateInStyleTree(Array)
#5 /home/derek/public_html/library/TMS/DataWriter/Modification.php(212): XenForo_Model_Template->compileMappedTemplatesInStyleTree(Array)
#6 /home/derek/public_html/library/TMS/DataWriter/Modification.php(182): TMS_DataWriter_Modification->_recompileAssociatedTemplates()
#7 /home/derek/public_html/library/XenForo/DataWriter.php(1385): TMS_DataWriter_Modification->_postSave()
#8 /home/derek/public_html/library/TMS/ControllerAdmin/Modification.php(179): XenForo_DataWriter->save()
#9 /home/derek/public_html/library/XenForo/FrontController.php(310): TMS_ControllerAdmin_Modification->actionSave()
#10 /home/derek/public_html/library/XenForo/FrontController.php(132): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))
#11 /home/derek/public_html/admin.php(13): XenForo_FrontController->run()
#12 {main}
 
Jake, one last thing... haha. Came across something else.

Code:
<xen:if is="!in_array({$field.field_id}, array('pano', 'iPG')) OR {xen:helper ismemberof, $visitor, 3, 17, 4}">
    <xen:if is="{$field.isEditable}">
</xen:if>

That above is my code.

Now, I want to add another, but have it set different. It would be like the first code:
Code:
<xen:if is="{$field.field_id} != 'YouTube' OR {xen:helper ismemberof, $visitor, 3, 7, 17, 4}">
    <xen:if is="{$field.isEditable}">
</xen:if>

The main thing is, the YouTube field can now be seen by one extra group, but I don't want that same group to see the fields 'pano' or 'iPG'.

Can I just add that code above the first one?

Try this:

Code:
<xen:if is="!in_array({$field.field_id}, array('pano', 'iPG', 'YouTube')) OR (in_array({$field.field_id}, array('pano', 'iPG')) AND {xen:helper ismemberof, $visitor, 3, 17, 4}) OR (in_array({$field.field_id}, array('YouTube')) AND {xen:helper ismemberof, $visitor, 3, 7, 17, 4})">
 
HTML:
<xen:foreach loop="$customFields" value="$field">
    <xen:if is="{$field.isEditable}">
        <xen:if is="{$user.customFields.add_a_banner_above_your_p} != 'Trévor' OR {xen:helper ismemberof, $visitor, 3}">
      <xen:include template="custom_field_edit" />
</xen:if>
    </xen:if>
</xen:foreach>

Don't work :/
 
Top Bottom