N
N
nulledbox2020-07-23 17:08:46
WordPress
nulledbox, 2020-07-23 17:08:46

How to assign a unique ID to a visitor in WordPress?

The bottom line is to find out whether a certain visitor was on the site or not.
I create 100-200 jobs in services. And for more than half, in order to record confirmation of visiting the site, I ask for a screenshot of the internal page.

And so a huge mass of screenshots is accumulated - an unnecessary and meaningless decision! And I want that after visiting the user of any page, he would see his unique number or ID (alphanumeric value) - this ID would be sent to me as a visit report. And on my side, I would open either a table or a textbook on the server where these IDs are recorded.

Has anyone come across such a solution? How can you identify a user and find out if he visited the site.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Sobolev, 2020-07-23
@san_jorich

if the user logs in, you will receive Last Login

function user_last_login( $user_login, $user ) {
    update_user_meta( $user->ID, 'last_login', time() );
}
add_action( 'wp_login', 'user_last_login', 10, 2 );

/**
 * Выводим время последнего входа
 *
 */

function wpb_lastlogin() {
  $last_login = get_the_author_meta('last_login');
  $the_login_date = human_time_diff($last_login);
  return $the_login_date;
}

If this is just a visitor, then you can make a confirmation form - for example, some field like a phone number, compared with the base + script to take the page, login time and other necessary data

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question