This is probably a simple question for someone who knows wordpress well.
I’m trying to execute a sql statement that updates a field every time a user logs in. Rather than create a whole plugin I thought I could just amend the login script to execute the SQL statement, but I am having trouble finding/deciding what file I should edit.
Should I edit the template file? Something like header.php check if the user is logged in and then execute or should I add it to the actual wp-login.php file?
Any thoughts are appreciated as I am new to wordpress and don’t know what the best practices are yet.
WordPress has many so-called action hooks that allow you to do thing when certain events occur. There is one called wp_login that fires whenever someone logs in.
You can add the following to your functions.php file:
This will get called whenever someone logs in.