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.
 
Admin CP -> Appearance -> Templates -> custom_fields_edit

Add the red code:

Rich (BB code):
<xen:foreach loop="$customFields" value="$field">
	<xen:if is="{$field.isEditable}">
		<xen:if is="{$field.field_id} != 'my_identifier' OR {xen:helper ismemberof, $visitor, 4}">
			<xen:include template="custom_field_edit" />
		</xen:if>
	</xen:if>
</xen:foreach>

You need to enter the field_id of the private field as well as the user_group_id of the privileged group.
 
Admin CP -> Appearance -> Templates -> custom_fields_edit

Add the red code:

Rich (BB code):
<xen:foreach loop="$customFields" value="$field">
<xen:if is="{$field.isEditable}">
<xen:if is="{$field.field_id} != 'my_identifier' OR {xen:helper ismemberof, $visitor, 4}">
<xen:include template="custom_field_edit" />
</xen:if>
</xen:if>
</xen:foreach>

You need to enter the field_id of the private field as well as the user_group_id of the privileged group.

Jake, if we have multiple fields we don't want edited to usergroups, do we copy the line in red and repeat, or do we add another beside the 'my_identifier' ?
 
Ok, here is the actual code I have:
Code:
<xen:if is="{$field.field_id} != 'pano' OR {xen:helper ismemberof, $visitor, 3, 17, 4}">
    <xen:if is="{$field.isEditable}">
</xen:if>
I want to add another field beside 'pano', called 'YouTube'. Does anyone know how to add that in also?
 
Ok, here is the actual code I have:
Code:
<xen:if is="{$field.field_id} != 'pano' OR {xen:helper ismemberof, $visitor, 3, 17, 4}">
    <xen:if is="{$field.isEditable}">
</xen:if>
I want to add another field beside 'pano', called 'YouTube'. Does anyone know how to add that in also?

Try this:

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

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?
 
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?


I would probably add to the first code to look like this

Code:
<xen:if is="!in_array({$field.field_id}, array('pano', 'iPG')) OR {xen:helper ismemberof, $visitor, 3, 17, 4} OR !{xen:helper ismemberof, $visitor, 7}">
    <xen:if is="{$field.isEditable}">
</xen:if>
 
This is what I have right now:
Code:
<xen:foreach loop="$customFields" value="$field">
<xen:if is="{$field.field_id} != 'YouTube' OR {xen:helper ismemberof, $visitor, 3, 7, 17, 4}">
</xen:if>
<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:if is="{$field.isEditable}">
</xen:if>
        <xen:include template="custom_field_edit" />

This part is working as it should ---> <xen:if is="!in_array({$field.field_id}, array('pano', 'mixpod', 'mixpodautoplay', 'mixpodplaylistlink', 'mixpodcolor1', 'mixpodcolor2', 'mixpodcolor3')) OR {xen:helper ismemberof, $visitor, 3, 17, 4}">

This part isn't ---> <xen:if is="{$field.field_id} != 'YouTube' OR {xen:helper ismemberof, $visitor, 3, 7, 17, 4}">
</xen:if>
 
You don't have anything between that if statement which is why nothing is showing. You have the <xen:if> then you close it.

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.
 
Top Bottom