XF 2.3 Blocking guests from seeing style-variation?

Dannymh

Well-known member
Licensed customer
I am having issues trying to hide the style chooser for guests. The reason i want to do this is because under google analytics I am getting absolutely hammered by guest users hitting the misc/style-variations link.
Screenshot 2026-02-12 at 3.08.50 pm.webp

I tried to set this in a template modification as follows on page_container

find:
Code:
<xf:if is="$xf.visitor.canChangeStyleVariation($xf.style)">
                                                <a href="{{ link('misc/style-variation') }}" rel="nofollow"
                                                    class="js-styleVariationsLink"
                                                    data-xf-init="tooltip" title="{{ phrase('style_variation') }}"
                                                    data-xf-click="menu" data-z-index-ref=".u-bottomFixer" role="button" aria-expanded="false" aria-haspopup="true">

                                                    <xf:fa icon="{{ $xf.style.getVariationIcon($xf.visitor.style_variation) }}" title="{{ phrase('style_variation') }}" />
                                                </a>

                                                <div class="menu" data-menu="menu" aria-hidden="true">
                                                    <div class="menu-content js-styleVariationsMenu">
                                                        <xf:macro name="style_variation_macros::variation_menu"
                                                            arg-style="{$xf.style}"
                                                            arg-live="{{ true }}" />
                                                    </div>
                                                </div>
                                            </xf:if>

replace with
Code:
<xf:if is="$xf.visitor.user_id">
                                            <xf:if is="$xf.visitor.canChangeStyleVariation($xf.style)">
                                                <a href="{{ link('misc/style-variation') }}" rel="nofollow"
                                                    class="js-styleVariationsLink"
                                                    data-xf-init="tooltip" title="{{ phrase('style_variation') }}"
                                                    data-xf-click="menu" data-z-index-ref=".u-bottomFixer" role="button" aria-expanded="false" aria-haspopup="true">

                                                    <xf:fa icon="{{ $xf.style.getVariationIcon($xf.visitor.style_variation) }}" title="{{ phrase('style_variation') }}" />
                                                </a>

                                                <div class="menu" data-menu="menu" aria-hidden="true">
                                                    <div class="menu-content js-styleVariationsMenu">
                                                        <xf:macro name="style_variation_macros::variation_menu"
                                                            arg-style="{$xf.style}"
                                                            arg-live="{{ true }}" />
                                                    </div>
                                                </div>
                                                </xf:if>
                                            </xf:if>

However this is not working and I still have the style variation for guests. as seen below

Screenshot 2026-02-12 at 2.43.59 pm.webp

Is there something I am doing wrong or something else I can do to change this?

Regards
Dan
 
Last edited:
i used the code on page_container template and it worked for me.

1780875179658.webp

hiding the link does not stop the bots from hitting it though. i still get like 15K-40K hits on a daily basis lol.

1780875239649.webp
 
Put in a redirect or page rule that sends guests to 403 for that page.

I also have challenge rules in on cloudflare that sends the “I am human” verification check for worst offending countries. I often have to chase the varying countries as they evolve constantly
 
It is not necessary to completely remove the style variation chooser for guests; making sure it does not use links for live variation switch is sufficient to stop bots from needlessly acccessing those URLs.


After applying the change it will take some time though to see requests go down as bots might still have / remember previously seen URLs and continue to access them.
 
Back
Top Bottom