How to insert username in wordpress with a plugin

0

I am trying to modify a plugin, I added a field that is called user_name, The plguin consists of counting the number of visitors to the page and who visited it through the ip .. what I want is for me to record the username in the table but I can not get it. this is the code

if ( ! $this->result ) {
        //aqui agarro el nombre de usuario logueado
        $user = wp_get_current_user();
        $usuario = $user->user_login;
        $wpdb->insert(
            $wpdb->prefix . "statistics_visitor",
            array(
                'last_counter' => $this->Current_date( 'Y-m-d' ),
                'referred'     => $this->get_Referred(),
                'agent'        => $this->agent['browser'],
                'platform'     => $this->agent['platform'],
                'version'      => $this->agent['version'],
                'ip'           => $this->get_IP(),
                'location'     => '000',
                //aqui es donde lo trato de insertar
                'user_name'    => $usuario,
            )
        );
    }

Any help I'm doing wrong? .. the plugin is called Wp-Statistic

    
asked by Hernan Chaparro 03.09.2018 в 16:54
source

0 answers