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

XF 1.4 Can I generate links on the user's requiring approval page based on registration fields?

Discussion in 'XenForo Questions and Support' started by cheracc, Sep 4, 2015.

  1. cheracc

    cheracc Member

    I don't know if this is possible without an addon, but this is what I would like to do.

    My website is a Minecraft community forum, and I don't want players getting on the server before they register on the website. We check usernames against a ban database before approving them, and the approval is done through PHP. So really, all I need is to generate some links on the "Users awaiting approval" page that my moderators can click on to approve/deny the user.

    If I didn't explain myself well enough or you have questions, let me know.
  2. Brogan

    Brogan XenForo Moderator Staff Member

    You could possibly do it with a custom user field which is moderator editable only.


    That could be linked to a user group promotion which provides the relevant permissions/access.
  3. cheracc

    cheracc Member

    Yes, that could possibly work. However, it seems like the custom field's variable substitutions can only access the value of the field itself? What if I wanted to get the user's username from the registration? Could I use a field ID for that? Such as {$username}?
    Last edited: Sep 4, 2015
  4. Brogan

    Brogan XenForo Moderator Staff Member

    If you want to pass the user name through to your custom PHP code when checking the field, then that is going to require custom development.
  5. cheracc

    cheracc Member

    I only need it in the link that gets generated by XenForo. So using your example above, it could be a custom field that's hidden to normal users where the Value Display HTML would be something like http://example.com/approve?username={$username}

    In this example {$username} would be whatever they put in the XenForo username field during registration. Is that possible?
  6. Brogan

    Brogan XenForo Moderator Staff Member

    A link wouldn't be generated by a custom user field, so it would require custom development.
  7. cheracc

    cheracc Member

    Let me attempt this a different way.

    I see that XenForo has an option to create Admin Template overrides by defining a new template with the name of the template you want to override. In the template XML, there is a section called users_awaiting_approval which I created with the following XML:

    <xen:title>{xen:phrase users_awaiting_approval}</xen:title>
    <xen:form action="{xen:adminlink 'users/moderated/update'}">
            <xen:foreach loop="$users" value="$user">
                            <xen:controlunit label="{xen:phrase user}:"><a href="{xen:adminlink users/edit, $user}" target="_blank">{$user.username}</a> ({$user.email})</xen:controlunit>
                            <xen:controlunit label="{xen:phrase joined}:"><xen:datetime time="{$user.register_date}" /></xen:controlunit>
                            <xen:if is="{$user.ip}">
                                    <xen:controlunit label="{xen:phrase ip}:"><a href="{xen:link misc/ip-info, '', 'ip={$user.ip}'}" target="_blank">{$user.ip}</a> <xen:if is="{$user.ipHost}">({$user.ipHost})</xen:if></xen:controlunit>
                            <xen:if is="{$user.spamDetails}">
                                    <xen:controlunit label="{xen:phrase spam_log}:"><ul>
                                            <xen:foreach loop="{$user.spamDetails}" value="{$detail}">
                                                    <li>{xen:escape $detail, false}</li>
                            <xen:controlunit label="foo">
                                    this is a test link: <a href="http://example.com/whitelist?username=[{$user.username}]>check</a>
                            <xen:radiounit label="{xen:phrase action}:" name="users[{$user.user_id}][action]">
                                    <xen:option value="none" selected="true">{xen:phrase do_nothing}</xen:option>
                                    <xen:option value="approve">{xen:phrase approve}</xen:option>
                                    <xen:option value="reject">
                                            <xen:label>{xen:phrase reject_and_delete_with_rejection_reason}:</xen:label>
                                            <xen:textbox placeholder="{xen:phrase optional}" name="users[{$user.user_id}][reject_reason]" size="45" />
                            <xen:checkboxunit label="">
                                    <xen:option name="users[{$user.user_id}][notify]" selected="!{$user.spamDetails}">{xen:phrase notify_user_if_action_was_taken}</xen:option>
            <xen:submitunit save="{xen:phrase process_users}" />
    Everything in there is default except for the controlunit with label="foo" that I added.

    The problem is, I'm not seeing this show up when I refresh the page. Is there a way to manually rebuild the template cache without going to /install and hitting the "Rebuild Master Data" button?
  8. cheracc

    cheracc Member

    Nevermind, I had the template name wrong. It's "user_moderated" not "users_awaiting_approval". I can edit the template under Admin Templates and the changes show up immediately. This should let me put whatever HTML I want in the Users Awaiting Approval page.

Share This Page