• webmasteral

    (@webmasteral)


    I know you said two years ago that you could not add a sort by IP function into this plugin but could you look at this request again and see if things have changed with the new versions on WP.

    I have had a few visitors register multiple usernames within minutes of each-other under one IP address and never log in so it would be nice if I could sort by IP to check to see if there are any other mass IP address site registrations

    Thanks for all your hard work and support to this plugin.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter webmasteral

    (@webmasteral)

    Iv been working on making the plugin sortable.

    Its not working yet but I thought Id share what iv done so far.

    <?php
    class Register_IP_Multisite {
        public function __construct() {
            add_action( 'init', array( &$this, 'init' ) );
        }
        public function init() {
    		add_action( 'user_register', array( $this,'log_ip') );
    		add_action( 'edit_user_profile', array( $this,'edit_user_profile') );
    		add_action( 'manage_users_custom_column', array( $this,'columns'), 10, 3);	
    		add_filter( 'manage_users_sortable_columns', array( $this ,'users_sortable_columns_wsp') );
    		add_filter( 'request', array( $this ,'users_orderby_column_wsp') );	
    		add_filter( 'plugin_row_meta', array( $this ,'donate_link'), 10, 2 );
    		if ( is_multisite() ) {
    			add_filter('wpmu_users_columns', array( $this ,'column_header_signup_ip'));
    		} else {
    			add_filter('manage_users_columns', array( $this ,'column_header_signup_ip'));
    		}
    	}
    
    	public function log_ip($user_id){
    		$ip = $_SERVER['REMOTE_ADDR']; //Get the IP of the person registering
    		update_user_meta($user_id, 'signup_ip', $ip); //Add user metadata to the usermeta table
    	}
    
    	public function edit_user_profile() {
    	        $user_id = (int) $_GET['user_id'];
    	?>
    	        <h3><?php _e('Signup IP Address', 'register-ip-mutisite'); ?></h3>
    	        <p style="text-indent:15px;"><?php
    	        $ip_address = get_user_meta($user_id, 'signup_ip', true);
    	        echo $ip_address;
    	        ?></p>
    	<?php
    	}
    
    	public function column_header_signup_ip($column_headers) {
    	    $column_headers['signup_ip'] = __('IP Address', 'register-ip-multisite');
    	    return $column_headers;
    	}
    
    	public function users_sortable_columns_wsp($column_headers) {
              $customwsp = array(
    		  // meta column id => sortby value used in query
              'signup_ip'    => 'ip',
              );
        return wp_parse_args($customwsp, $column_headers);
    	}
    
    	public function users_orderby_column_wsp( $varswsp ) {
            if ( isset( $varswsp['orderby'] ) && 'ip' == $varswsp['orderby'] ) {
                    $varswsp = array_merge( $varswsp, array(
                            'meta_key' => 'ip',
                            'orderby' => 'meta_value_num'
                    ) );
            }
        return $varswsp;
    	}
    
    	public function columns($value, $column_name, $user_id) {
    		global $modewsp;
    		$modewsp = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode'];
            if ( $column_name == 'signup_ip' ) {
                $ip = get_user_meta($user_id, 'signup_ip', true);
                if ($ip != ""){
                    $theip = '<span>'. $ip .'</span>';
    				if ( has_filter('ripm_show_ip') ) {
    					$theip = apply_filters('ripm_show_ip', $theip);
    				}
                    return $theip;
                } else {
                    $theip = '<em>'.__('None Recorded', 'register-ip-multisite').'</em>';
                    return $theip;
               }
            }
    
    	    return $value;
    	}
    }
    new Register_IP_Multisite();
    Plugin Author Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    I actually have an idea how to do this. What I need is a TARDIS so I have the time.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Sort by IP’ is closed to new replies.