As you probably already noticed yourself $wpdb
doesn't have any hooks that you can use.
The answer @brennan gave already sounds like an interesting approach, but probably won't help if you have to solve it in code without access to the DB to create the trigger.
I have another idea, that although hacky, might also work depending on what exactly your requirements are.
So you said "[…] able to hook in when the plugin adds a row to a plugin-specific table […]". So I assume you really only are talking about adding rows, not editing existing. I am also assuming that the table has some auto incrementing ID.
If that is the case what about this approach:
- Store the highest ID of a row in the relevant table, e.g. in an option.
- Check if the stored ID is lower than the current highest ID.
- Get all rows from the last stored ID to the current ID.
- Do whatever you need to do with that information.
When you do this really depends on the exact requirements of your "update some other data elsewhere". You could do it in the shutdown
hook, in CRON that runs every couple minutes, some hook from the plugin that reliably runs after updates or - thinking about your "updating the status column for the user associated to the log" - right before the reading of the user status.
EDIT: the comment by @birgire just made me realize another thing: You can try hooking to query
to set a flag if the query is the one you care about and only do the check from above if that flag is set to true. This should be way better from a performance perspective.
I am intentionally leaving out any specific code, but I hope the approach is clear.
wpdb
class for DB interaction?$wpdb->update
/$wpdb->insert
to add the log.