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

Hiding "Home page" profile field from guests (spamming issue)

Discussion in 'XenForo Questions and Support' started by CyclingTribe, Aug 16, 2012.

  1. CyclingTribe

    CyclingTribe Well-Known Member

    I've got the same problem on all my XF boards where spammers register and add their spam URL to their profile home page field - which is then displayed to everyone.

    How would I hide this field from guests (and/or selected usergroup IDs) so that the URLs are not spidered by search engine bots?

    Thanks,
    Shaun :D
     
  2. Chris D

    Chris D XenForo Developer Staff Member

    The URLs won't be followed by search engines as they have the nofollow attribute set.

    EDIT: To answer your question though.

    member_view template change:

    Code:
    <xen:if is="{$user.homepage}">
    
    <dt>{xen:phrase home_page}:</dt>​
    <dd><a href="{xen:string censor, $user.homepage, 'x'}" rel="nofollow" target="_blank" itemprop="url">{xen:string censor, $user.homepage}</a></dd>​
    </xen:if>
    to:

    Code:
    <xen:if is="{$user.homepage} AND {xen:helper ismemberof, $visitor, 3, 4, 5}">
    
    <dt>{xen:phrase home_page}:</dt>​
    <dd><a href="{xen:string censor, $user.homepage, 'x'}" rel="nofollow" target="_blank" itemprop="url">{xen:string censor, $user.homepage}</a></dd>​
    </xen:if>
    Where "3, 4, 5" are usergroup IDs.
     
    Simon and CyclingTribe like this.
  3. CyclingTribe

    CyclingTribe Well-Known Member

    Thanks Chris, much appreciated. (y)
     
  4. Simon

    Simon Active Member

    I have the same problem and thanks for the code above. This does remove the homepage from displaying in the left hand side of the user profile. However, I have also noticed that the home page URL is also displayed in the information tab in the user profile and the recent activity tab. I guess to stop the spam the easiest way would be to block the user from entering it altogether.

    Any idea on what template I need to edit and some example code?

    Thanks in advance.

    Simon

    Update: I edited template account_personal_details template and removed:
    Code:
    <dl class="ctrlUnit">
                <dt><label for="ctrl_homepage">{xen:phrase home_page}:</label></dt>
                <dd><input type="url" name="homepage" value="{$visitor.homepage}" id="ctrl_homepage" class="textCtrl" /></dd>
            </dl>
    This removed the option to add a homepage for all users.
    I just need to figure out a way to add a usergroup condtion to add the code back.
     
  5. Chris D

    Chris D XenForo Developer Staff Member

    It could be removed from that tab too, would just be another template edit somewhere.

    Blocking the homepage field though isn't going to prevent spammers. They will still register and they'll put a URL somewhere else, or in their signature, or start a new thread... All that blocking the homepage field will do is potentially frustrate some of your visitors who would use it legitimately.

    I take quite a relaxed view of spam on my board. It happens, and it is quite regular, but that's why we have moderators. It's one of those battles you'll never win.

    However, if you do want to effectively disable the input, or at least restrict it to more trusted usergroups.

    account_personal_details template change:

    Code:
    <dl class="ctrlUnit">
    
    <dt><label for="ctrl_homepage">{xen:phrase home_page}:</label></dt>​
    <dd><input type="url" name="homepage" value="{$visitor.homepage}" id="ctrl_homepage" class="textCtrl" /></dd>​
    </dl>
    to

    Code:
    <xen:if is="{xen:helper ismemberof, $visitor, 3, 4, 5}">
    
    <dl class="ctrlUnit">​
    <dt><label for="ctrl_homepage">{xen:phrase home_page}:</label></dt>​
    <dd><input type="url" name="homepage" value="{$visitor.homepage}" id="ctrl_homepage" class="textCtrl" /></dd>​
    </dl>​
    </xen:if>
    Where 3, 4, 5 are the usergroups who are allowed to edit the homepage field.

    By the way, I've not tested either of these, I'm pretty sure they should work, though.
     
    Coop1979 and CyclingTribe like this.
  6. CyclingTribe

    CyclingTribe Well-Known Member

    Actually, that's a much better idea - disallowing the editing of the field (controlling which usergroups can see it) would work much better for my boards because I use usergroup promotions and the spammers never graduate past the registered group because they spam and leave.

    Thanks Chris, I'll give this a try. (y)

    Cheers,
    Shaun :D
     
    Chris D likes this.
  7. Coop1979

    Coop1979 Well-Known Member

    Chris - What if we just want to exclude 2 usergroups - like "Newly Registered" and "Banned"? Let's say they are groupids 6 and 7.
     
  8. Chris D

    Chris D XenForo Developer Staff Member

    Forgive lack of formatting I am on my mobile. It's almost identical but notice the !

    This basically says display the field if NOT those groups.

    <xen:if is="!{xen:helper ismemberof, $visitor, 6, 7}">
    <dl class="ctrlUnit">
    <dt><label for="ctrl_homepage">{xen:phrase home_page}:</label></dt>
    <dd><input type="url" name="homepage" value="{$visitor.homepage}" id="ctrl_homepage" class="textCtrl" /></dd>
    </dl>
    </xen:if>
     
    Coop1979 and CyclingTribe like this.

Share This Page