Conditional Help Needed Message Template and Usergroups

Michael

Active member
Hey I am trying to display some content for members of one usergroup within the message template, I am trying to use this but it doesnt appear to work:

<xen:if is="{xen:helper ismemberof, $user, 4}">
<xen:if is="{$message.customFields.my_test}">
<p>{$message.customFields.my_test}</p>
</xen:if>
</xen:if>

This seems to work fine within the message_user_info template, any ideas?

Thank you :)
 
$message and $user are mapped in the message template, so it should work.

This outputs the fieldId of my selection, so custom data is there:
{$message.customFields.iwdrp_race.fieldId}

Try this:
Code:
<xen:if is="{$message.customFields.my_test.fieldId}">
</xen:if>
 
Thanks Lawrence, that appears to output only the first character that the user has entered, without fieldId it works as it should, it seems the usergroup part is incorrect, I am adding myself to the usergroup, filling my field but it is only outputting it when I dont use the usergroup conditional. Any ideas on how to fix that? That conditional for the usergroup works perfectly fine in message_user_info but not message.

Thank you.
 
Try $visitor in replace of $user for your conditional.

I only tested this with a radio option choice, and needed the fieldId to make it work, that may be the reason why you do not need the fieldId?
 
Try $visitor in replace of $user for your conditional.

I only tested this with a radio option choice, and needed the fieldId to make it work, that may be the reason why you do not need the fieldId?

Visitor isnt working either :( That sounds right yeah this is just a user filled in field.
 
<xen:if is="{xen:helper ismemberof, $visitor, 4}">
Hello
</xen:if>

The above worked for me in message template. Be sure you place it in the right styles message template, :)

Does it work for you when you have it around a field so the field will only display for those in the group but show to all?
 
I have tried both of these:

Code:
<xen:if is="{xen:helper ismemberof, $user, 4}">
<xen:if is="{$message.customFields.my_test}">
<p>{$message.customFields.my_test}</p>
</xen:if>
</xen:if>

and


Code:
<xen:if is="{xen:helper ismemberof, $visitor, 4}">
<xen:if is="{$message.customFields.my_test}">
<p>{$message.customFields.my_test}</p>
</xen:if>
</xen:if>

but they only show/work as they should with this removed:

Code:
<xen:if is="{xen:helper ismemberof, $visitor, 4}">
 
</xen:if>

I am part of the usergroup too so it should show the output to me in the message.

:)
 
<xen:if is="{xen:helper ismemberof, $visitor, 4}">
<xen:if is="{$message.customFields.iwdrp_race.fieldId}">
<p>Slavik likes lime</p>
</xen:if>
</xen:if>

This works in message template. The issue you are having is displaying the actual data. It depends on the input fields: text fields, multiple select units, radio units, etc.
 
I don't use custom fields, I only have them to develop my roster add-on, and that data is handled by php and sent to a custom template. If you can wait until tomorrow, I'll look more closely into it, and get it to display in the message template.

Thanks Lawrence that is perfectly fine for me as this can wait :)
 
I'm not sure exactly what you are trying to do, but if you are trying to display the contents of a custom field, only to a certain usergroup and only if the field is filled in, this works on my forum (in this example, displaying "latitude_member_map" to admin group 3).

Code:
<xen:if is="{xen:helper ismemberof, $visitor, 3}">
<xen:if is="{$visitor.customFields.latitude_member_map}">
<p>{$visitor.customFields.latitude_member_map}</p>
</xen:if>
</xen:if>
 
I'm not sure exactly what you are trying to do, but if you are trying to display the contents of a custom field, only to a certain usergroup and only if the field is filled in, this works on my forum (in this example, displaying "latitude_member_map" to admin group 3).

Code:
<xen:if is="{xen:helper ismemberof, $visitor, 3}">
<xen:if is="{$visitor.customFields.latitude_member_map}">
<p>{$visitor.customFields.latitude_member_map}</p>
</xen:if>
</xen:if>

Thank you, what I am wanting is this:

Bob fills in his computer information in his Personal Details as: Asus Motherboard, 6GB RAM. Bob is a premium member in usergroup 4 and can therefore have this display in the message template to himself and others. Ralph on the other hand is not a premium member, he has the field filled in from his last subscription, he can see Bobs custom field but his own does not display to anyone, when Ralph is moved into usergroup 4 it begins to show again. All other members can see when someone in usergroup 4 has filled theirs in.

In other words, I want the field to show in the message template only when members are in group 4 which is an additional usergroup but show to everyone the output when the particular member is in group 4.

I hope thats clearer for what I am wanting to do, it sounds more complicated like that :D
 
I understand. My example just displays the logged in user's custom field data to himself.

Does my code work if you change all the $visitor to $user? (So it's similar to your OP but replacing $message with $user).
 
Yes - but only in certain places, where $user would be available. For example, it works to show under the username (under the avatar next to a post) in the message_user_info template, a custom field value for that user only if they are a member of that specific group and the field is filled in.

I tried it elsewhere for example under a post but it was blank so I assumed in that part of the template the $user value is not available, in other words that part of the template was outside of whatever loop was dealing with displaying data specific to a user.

Hope that makes sense, so yes it does work in some places and I have confirmed this on my own forum. That's about the limits of my knowledge here, sorry.
 
Back
Top Bottom