• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

How to extend user criteria (for use in trophies, upgrades and notices/notifications) 1.0

No permission to download


Active member
Hey !

When I create the Code Event Listener I have this error :
The server responded with an error. The error message is in the JavaScript console.
Help :(

Chris D

XenForo developer
Staff member
That's not the error. It says there will be an error in the console.

There's also likely an error in your server error log.
Great tutorial, I am writing my first addOn for XenForo and this was a great help. I do have one question, if I wanted to save a new user criteria (say instead of something calculated like has_avatar, I wanted has_degree where the checkbox would save a value of TRUE or FALSE), what is the correct way to go about adding additional values?
Hi Chris
I bought Gritternotificattion and install it, it is very handy!

I saw this UserCriteriaExample and install it, do I need to do anything with the code?

So, how can the members get the trophy when they put the avatar?

I setup a new Trophy in User > Trophies then in the Awarder Trophy If.. I checked User has an Avatar.

Should this get the member Trophy point in the Alert?
I did try setup myself a new user and add the Trophy but doesn't seem to get any alert regarding the Trophy..
Hey Chris!
First of all thanks for the great tutorial!
Followed your tutorial and managed to get it working for what I needed at first but I need something a little different now.
I have the AD Credits addon installed and wanted to make it easy for others to use custom milestones, so I wanted to create an criteria that allowed you to change the amount needed freely. I got it to show just fine but I'm a little confused about where the $data array comes from and how I can add a new key, value to that. This is what I have right now:

$userCriteria = $template->getParam('userCriteria');
            $checked = $userCriteria['has_x_currency'] ? 'checked' : '';
            $contents .= '<li>
                                <input type="checkbox" id="ucrit_adcredit" class="Disabler" value="has_x_currency" name="user_criteria[has_x_currency][rule]" ' . $checked .'>
                                User has at least X Yuan:
                            <div id="ucrit_adcredit_Disabler" class="criteriaQualifier disabled">
                                <input type="text" id="ctrl_user_criteriaadcredit" class="textCtrl number SpinBox disabled" min="0" step="7" size="5" value="0" name="user_criteria[has_x_currency][data][has_x_currency]" autocomplete="off" disabled="">
And the rule part:

case 'has_x_currency':
                if ($user['adcredit'] > $data['adcredit'])
                    $returnValue = true;
In the attachement you can see that it is shown at the right position and how I want it to be shown.
The problem now is that the value of the field isn't saved (it always resets to 0 when I reopen the trophy) and that the comparison seems to compare it 0.

I'm still pretty new to this so my mistakes may be a little clumsy.
Thanks to whoever tries to help me in advance! :)