XF 2.2 How to disable/hide IP logging of certain users/admins?

I want to disable/spoof the IP logging of admins on my forum. Since there is no point in exposing their IP to mods. How can I do this? I looked this up but only found an old 1.4 plugin that's irrelevant now. What would be the easiest way of achieving this?
 
No, there are no settings.
I understood that already. Just asked in case it was recently added or to atleast make the devs consider it. Tried your add on. Immediately caused server errors and couldn't retrieve any ip's any longer. No offense but that's what I mean. This should be a setting or easily done in code. Easiest way I could think is maybe a cron job with db operation but that's not really elegant.
 
I've had no reports of errors. Please post them in the addon thread so they can be investigated.

There are a lot of things individuals consider should be in the core, but the reality is that it's not going to hapoen. That is why there are addons, to extend the core to suit individuals needs/wants.
 
The only way you could do that in the core settings is to disable the permission for mods or the user in question from viewing ips at all. And only allow admins to view ip addresses. Then they wouldn't be able to. As far as keeping admins ip addresses private, there really is no way in the core Xenforo as this is all based around the "can view ip addresses" permission found in permission settings.
 
I hope it helps someone..

src/XF/repository/Ip.php

line 21-38 replace;


PHP:
public function logIp($userId, $ip, $contentType, $contentId, $action = '')
    {      
        $entity = $this->em->create('XF:Ip');
        $entity->user_id = $userId;
       $removeip= array ('1','2','3');  /* 1,2,3 sample user id */ 
         if (in_array($userId,$removeip)) {
                    $entity->ip = '1.1.1.1';
        } else {
                     $entity->ip = $ip;
         }
        

        $entity->content_type = $contentType;
        $entity->content_id = $contentId;
        $entity->action = $action;

        if ($entity->save(false))
        {
            return $entity;
        }
        else
        {
            return null;
        }
    }
 
I hope it helps someone..

src/XF/repository/Ip.php

line 21-38 replace;


PHP:
public function logIp($userId, $ip, $contentType, $contentId, $action = '')
    {     
        $entity = $this->em->create('XF:Ip');
        $entity->user_id = $userId;
       $removeip= array ('1','2','3');  /* 1,2,3 sample user id */
         if (in_array($userId,$removeip)) {
                    $entity->ip = '1.1.1.1';
        } else {
                     $entity->ip = $ip;
         }
       

        $entity->content_type = $contentType;
        $entity->content_id = $contentId;
        $entity->action = $action;

        if ($entity->save(false))
        {
            return $entity;
        }
        else
        {
            return null;
        }
    }
I guess it would also need to be done in the session activity?
 
You could edit the template helper_ip

To look something similar to this:
HTML:
            <xf:formrow label="{{ phrase('content_ip') }}">
                <xf:if is = "$user.isMemberOf(3)">
                    <strong>127.0.0.1</strong> (localhost)
                <xf:else />
                    <strong><a class="ip" href="{{ link('misc/ip-info', null, {'ip': $ip|ip}) }}" target="_blank">{$ip|ip}</a></strong> {$ip|host|parens}
                </xf:if>
            </xf:formrow>

            <xf:if is="$user">
                <xf:set var="$registerIp" value="{$user.getIp('register')}" />
                <xf:if is="$registerIp">
                    <xf:if is = "$user.isMemberOf(3)">
                        <xf:formrow label="{{ phrase('user_registration_ip') }}">
                            <strong>127.0.0.1</strong> (localhost)
                        </xf:formrow>
                    <xf:else />
                        <xf:formrow label="{{ phrase('user_registration_ip') }}">
                            <strong><a class="ip" href="{{ link('misc/ip-info', null, {'ip': $registerIp|ip}) }}" target="_blank">{$registerIp|ip}</a></strong> {$registerIp|host|parens}
                        </xf:formrow>
                    </xf:if>
                       
                </xf:if>

The user that you clicked "IP" on on posts not in the Administrative group:
1733509359691.webp

Added to Administrative group:
1733509373845.webp

Also protects registration IP address.
1733509552083.webp

You can expand on this with more conditionals where if the user is an admin, they can view the IP address of other admins on the front end -- but they can on the back end.

This keeps it simple.

Change the IP and change the link to the IP address for certain users, etc., all doable without an add on.

You need to do something similar to the templates member_ip_list and member_shared_ips_list to cover these two overlays:

1733510222485.webp

I'm not too certain where else (on the front end) IPs are shown. But, easily found by searching phrases, then search templates for that phrase.
 
Back
Top Bottom