XF 2.3 Limit Birthday Widget to specific usergroup

PaulProe

Member
I am trying to limit the displayed birthdays in the Xenforo Birthday Widget to a specific usergroup. The widget has a Display Condition which says "This should be entered as a template-style expression."

Searching the forums, I find suggestions like "<xf:if is="$xf.visitor.isMemberOf(x)">; where x is the usergroup ID but when I try that I get an error "Display condition: Line 1: Syntax error"

I know nothing about template expressions. Can anyone help identify what is the correct expression to limit this to usergroup 32 We are running version 2.3

Thanks
 
I am trying to limit the displayed birthdays in the Xenforo Birthday Widget to a specific usergroup. The widget has a Display Condition which says "This should be entered as a template-style expression."

Searching the forums, I find suggestions like "<xf:if is="$xf.visitor.isMemberOf(x)">; where x is the usergroup ID but when I try that I get an error "Display condition: Line 1: Syntax error"

I know nothing about template expressions. Can anyone help identify what is the correct expression to limit this to usergroup 32 We are running version 2.3

Thanks
I might be wrong, but I think you just use the bit between the “quotes”

Try

$xf.visitor.isMemberOf([32])
 
I might be wrong, but I think you just use the bit between the “quotes”

Try

$xf.visitor.isMemberOf([32])
I tried that and the options will accept the code however it doesn't work - doesn't show any birthdays, those you want or those you don't want.

Is 'visitor' the correct term. I equate visitor as the person viewing the site. Is there a page or reference that lists the various terms that make up this line of code?
 
I entered the expression as suggested: $xf.visitor.isMemberOf([32])

No quotes, no other characters. I had three test users, all with the same birthdate. One admin, one member, one registered user. Member is usergroup 32. The members birthday showed up on the birthday calendar but it did not show on the widget. When I removed the code, it did appear. The other two did not appear on the calendar or on the widget.
 
I've narrowed it down a little more. I put in three different persons with the same birthdate. One is a regular user, one is a member user and one is an admin user. Only the member user is in usergroup 37.

I then entered this in the Display Condition field: $xf.visitor.isMemberOf([37]) I also tried it without the brackets $xf.visitor.isMemberOf(37)

In both code cases, I the regular users birthday notice did not appear. Good! But also in both case, the admin user's birthday did appear, even though they were not a member of usergroup 37

Any ideas why the code will not limit the search to just usergroup 37?
 
The display conditions just control whether or not to display the widget, meaning the conditional will cause the widget to be displayed to users belonging to group 37. It has no bearing over the content of the widget. You could instead edit the widget_birthday template and replace the wrapper with a content check and then wrap the user list items in the condition. Untested:

HTML:
<xf:if contentcheck="true">
    <div class="block"{{ widget_data($widget) }}>
        <div class="block-container">
            <h3 class="block-minorHeader">{$title}</h3>
            <div class="block-body block-row">
                <ul class="listHeap">
                    <xf:contentcheck>
                        <xf:foreach loop="$users" value="$user" if="$user.isMemberOf(27)">
                            <li>
                                <xf:avatar user="$user" size="s" img="true" />
                            </li>
                        </xf:foreach>
                    </xf:contentcheck>
                </ul>
            </div>
        </div>
    </div>
</xf:if>
 
Back
Top Bottom