Log IP of users who click a button? [closed]

It depends on how the button works.

For instance, you can make an API. When the button is clicked, you can call the api via Ajax and save the IP during the process.

Or most likely you will write ip via action hook, if the button call the hook. In this case, you will use user agent.