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

How To Stop Guests Using Contact Us?

Discussion in 'XenForo Questions and Support' started by Inkman, Jul 14, 2013.

  1. Inkman

    Inkman Active Member

    Can anyone tell me please how i can stop guests from using the contact us form?
     
  2. Brogan

    Brogan XenForo Moderator Staff Member

    Edit the template and wrap it in a guest conditional statement.
     
  3. Jeremy

    Jeremy XenForo Moderator Staff Member

    In template contact add replace it with this:
    HTML:
    <xen:title>{xen:phrase contact_us}</xen:title>
    <xen:if is="{$visitor.user_id}">
    
    <form action="{xen:link 'misc/contact'}" method="post" class="xenForm formOverlay AutoValidator">
    
        <xen:if is="{$visitor.user_id} == 0">
            <dl class="ctrlUnit">
                <dt><label for="ctrl__guestUsername">{xen:phrase your_name}:</label></dt>
                <dd><input type="text" name="_guestUsername" value="{$visitor.username}" id="ctrl__guestUsername" class="textCtrl" autofocus="true" /></dd>
            </dl>
           
            <dl class="ctrlUnit">
                <dt><label for="ctrl_email">{xen:phrase your_email_address}:</label></dt>
                <dd><input type="text" name="email" id="ctrl_email" class="textCtrl" /></dd>
            </dl>
        <xen:else />
            <dl class="ctrlUnit">
                <dt><label>{xen:phrase your_name}:</label></dt>
                <dd>{$visitor.username}</dd>
            </dl>
           
            <dl class="ctrlUnit">
                <dt><label for="ctrl_email">{xen:phrase your_email_address}:</label></dt>
                <dd>{$visitor.email}</dd>
            </dl>
        </xen:if>
    
        <xen:include template="helper_captcha_unit" />
    
        <dl class="ctrlUnit">
            <dt><label for="ctrl_subject">{xen:phrase subject}:</label></dt>
            <dd><input type="text" name="subject" class="textCtrl" id="ctrl_subject" /></dd>
        </dl>
    
        <dl class="ctrlUnit">
            <dt><label for="ctrl_message">{xen:phrase message}:</label></dt>
            <dd><textarea name="message" class="textCtrl Elastic" id="ctrl_message" rows="5"></textarea></dd>
        </dl>
    
        <dl class="ctrlUnit submitUnit">
            <dt></dt>
            <dd><input type="submit" value="{xen:phrase send_message}" accesskey="s" class="button primary" /></dd>
        </dl>
    
        <input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}" />
    </form>
    <xen:else />
    <!-- WHAT YOU WANT DISPLAYED TO A GUEST HERE -->
    </xen:if>
    This is doing as Brogan states.
     
    CaptainMorgan, CallieJo and Inkman like this.
  4. Jeremy

    Jeremy XenForo Moderator Staff Member

    And to even further this, you can add this change in footer to remove the link from the footer:
    Code:
    <xen:edithint template="footer.css" />
    
    <xen:hook name="footer">
    <div class="footer">
        <div class="pageWidth">
            <div class="pageContent">
                <xen:if is="{$canChangeStyle} OR {$canChangeLanguage}">
                <dl class="choosers">
                    <xen:if is="{$canChangeStyle}">
                        <dt>{xen:phrase style}</dt>
                        <dd><a href="{xen:link 'misc/style', '', 'redirect={$requestPaths.requestUri}'}" class="OverlayTrigger Tooltip" title="{xen:phrase style_chooser}" rel="nofollow">{$visitorStyle.title}</a></dd>
                    </xen:if>
                    <xen:if is="{$canChangeLanguage}">
                        <dt>{xen:phrase language}</dt>
                        <dd><a href="{xen:link 'misc/language', '', 'redirect={$requestPaths.requestUri}'}" class="OverlayTrigger Tooltip" title="{xen:phrase language_chooser}" rel="nofollow">{$visitorLanguage.title}</a></dd>
                    </xen:if>
                </dl>
                </xen:if>
               
                <ul class="footerLinks">
                <xen:hook name="footer_links">
                <xen:if is="{$visitor.user_id}">
                    <xen:if is="{$xenOptions.contactUrl.type} === 'default'">
                        <li><a href="{xen:link 'misc/contact'}" class="OverlayTrigger" data-overlayOptions="{&quot;fixed&quot;:false}">{xen:phrase contact_us}</a></li>
                    <xen:elseif is="{$xenOptions.contactUrl.type} === 'custom'" />
                        <li><a href="{$xenOptions.contactUrl.custom}" {xen:if {$xenOptions.contactUrl.overlay}, 'class="OverlayTrigger" data-overlayOptions="{&quot;fixed&quot;:false}"'}>{xen:phrase contact_us}</a></li>
                    </xen:if>
                    </xen:if>
                    <xen:if is="{$homeLink}"><li><a href="{$homeLink}">{xen:phrase home}</a></li></xen:if>
                    <li><a href="{$requestPaths.requestUri}#navigation">{xen:phrase go_to_top}</a></li>
                    <li><a href="{xen:link forums/-/index.rss}" rel="alternate" class="globalFeed" target="_blank"
                        title="{xen:phrase rss_feed_for_x, 'title={$xenOptions.boardTitle}'}">{xen:phrase rss}</a></li>
                </xen:hook>
                </ul>
               
                <span class="helper"></span>
            </div>
        </div>
    </div>
    
    <div class="footerLegal">
        <div class="pageWidth">
            <div class="pageContent">
                <div id="copyright">{xen:phrase xenforo_copyright}</div>
                <xen:hook name="footer_after_copyright" />
    
                <ul id="legal">
                <xen:hook name="footer_links_legal">
                    <xen:if is="{$tosUrl}"><li><a href="{$tosUrl}">{xen:phrase terms_and_rules}</a></li></xen:if>
                    <xen:if is="{$xenOptions.privacyPolicyUrl}"><li><a href="{$xenOptions.privacyPolicyUrl}">{xen:phrase privacy_policy}</a></li></xen:if>
                </xen:hook>
                </ul>
           
                <xen:if is="{$debugMode}">
                    <xen:if hascontent="true">
                        <dl class="pairsInline" title="{$controllerName}-&gt;{$controllerAction}{xen:if $viewName, ' ({$viewName})'}">
                        <xen:contentcheck>
                            <xen:if is="{$page_time}"><dt>{xen:phrase timing}:</dt> <dd><a href="{$debug_url}">{xen:phrase x_seconds, 'time={xen:number $page_time, 4}'}</a></dd></xen:if>
                            <xen:if is="{$memory_usage}"><dt>{xen:phrase memory}:</dt> <dd>{xen:phrase x_mb, 'size={xen:number {xen:calc "{$memory_usage} / 1024 / 1024"}, 3}'}</dd></xen:if>
                            <xen:if is="{$db_queries}"><dt>{xen:phrase db_queries}:</dt> <dd>{xen:number {$db_queries}}</dd></xen:if>
                        </xen:contentcheck>
                        </dl>
                    </xen:if>
                </xen:if>
               
                <span class="helper"></span>
            </div>
        </div>   
    </div>
    </xen:hook>
     
    CallieJo and Inkman like this.
  5. Inkman

    Inkman Active Member

    Excellent it worked perfect, many thanks.
     

Share This Page