A
A
alexeev7772020-07-14 20:51:29
WordPress
alexeev777, 2020-07-14 20:51:29

Identifying user actions on a Wordpress site?

Hello! Tell me, please, is it possible to identify the user who performed the action on the site? That is, I have a button on the page that leads to a third-party resource, is it possible to understand which specific registered user clicked on it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Orkhan Hasanli, 2020-07-14
@azerphoenix

Hello!
And how exactly do you want to understand which user clicked on it?
1) Yandex Metrica - Webvisor. Will provide information about the ip, browser and OS of the user.
2) If you need to track actions in the site admin panel, then https://wp-stream.com/
3) As an option, on pressing the button, hang up a js script that, on click, sends information about the click to the server, and then it is identified on the server using PHP user if he is authorized and this or that action is performed, for example, a letter arrives that such and such a user has clicked on such and such a button.

S
Sergey Ermilov, 2020-07-14
@sergeiermilov

You can use the get_current_user_id() function and use it on all active elements to keep track of:

<?php $user_id = get_current_user_id(); ?>
<a href="/my-plugin-url<?php echo $user_id; ?>">View/Download plugin</a>

Or just use it in links:
https://www.example.com/somepage/?userid=12
It is considered not always safe and 100% accurate, because some "smart people" like to copy and paste links.
It might make sense to set a session variable to track access to your site after a user logs in.
Foreign sites suggested the following solution:
1. create a GUID value that is unique for this user after logging in and save it for the session
2. create other necessary variables
3. associate the GUID with other variables
4. add this value to the URL
5 .give the visitor the url 6.when the
user clicks on the url check the GUID value with the session variable to make sure it matches the GUID in the url
If everything is OK, then OK, and if not, if not, we write a warning / error message to the visitor asking him to log in and try again.
The GUID can be easily compromised, so make it 40 characters long. GUID generators can be googled.
Store it as a session variable, then it will be available to the user as long as he stays on your site.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question