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

Custom user criteria

Discussion in 'XenForo Development Discussions' started by ceribik, Jan 17, 2012.

  1. ceribik

    ceribik Active Member

    Does anybody know how to create new user criteria, e.g. for use in notices? Couldn't find anything by searching.

    Thanks :)
  2. steel_curtain

    steel_curtain Well-Known Member

    Not sure if this works for what you're trying to do, but you could simply set it up like this.

    Privileges and Status - Select user is logged in, and also user state is valid.
    Content and Achievements - User has posted no more than X messages, set to zero.

    Turn off the Notice may be dismissed option as well if you'd like, then the notice will remain until the member makes their first post.
  3. ceribik

    ceribik Active Member

    That's not what I'm looking for. I just need the ability to create new criteria.
  4. ceribik

    ceribik Active Member

  5. steel_curtain

    steel_curtain Well-Known Member

    The hook you listed above is what you need. It's a hook into the admin template helper_criteria_user. Look through that template to see how the options are formatted. Create a new code event listener listening to template_hook with your content to insert, and add it to your add-on.
  6. Morgan

    Morgan Active Member

    Has anyone released an addon that implements this? I'd like to see an example if possible. Would rather avoid the trial and error phase if possible!
  7. Morgan

    Morgan Active Member

    So I've implemented an admin template, setup a user_criteria and all is working except when I edit a notice the previous values do not show up. This is the template I am using, am I missing something?

    <template title="steam_helper_criteria_privs" version_id="1" version_string="1.0.0"><![CDATA[
        <label><input type="checkbox" name="user_criteria[steam_state][rule]" value="steam_state" class="Disabler" id="ucrit_steam_state" {xen:checked $userCriteria.steam_state} />{xen:phrase steam_state_is}</label>
        <div class="criteriaQualifier" id="ucrit_steam_state_Disabler">
            <xen:select name="user_criteria[steam_state][data][state]" value="{$userCriteria.steam_state.state}" inputclass="autoSize">
                <xen:option value="associated">{xen:phrase steam_state_associated}</xen:option>
                <xen:option value="deassociated">{xen:phrase steam_state_deassociated}</xen:option>
  8. Morgan

    Morgan Active Member

    Oh, I see. I had to do:
    array_merge($hookParams, $template->getParams())
    Is there somewhere that would explain what $hookParams and $template->getParams() are and how the differ? I doubt I should be merging these.
  9. James

    James Well-Known Member

    $hookParams are the parameters that are passed via the hook, such as:
    <xen:hook name="some_hook_name" params="{xen:array forum={$forum}, thread={$thread}}">
    $template->getParams are the parameters available to the template (usually $viewParams).
    Morgan likes this.

Share This Page