picking up current userid in a sql trigger

[ad_1]

I have a database app that I'm using with wordpress, that creates a log when a certain field is updated in a database table (not the wordpress table). The trigger works giving me a before and after value for a particular field.

I'm trying to figure out if there is a way to have the trigger pick up the current user of wordpress. So I know there is: get_current_user_id() that I can use from php, but given that the trigger is in the table being updated, I can't figure out how I might be able to pick up the userid for the current user, and use it to add to the record being created by the trigger. Anyone have any thoughts?

[ad_2]
2 Comments
  1. Store it in a session or a temporary field, then use that value in your SQL trigger

  2. Is this for a log/history? We did something recently and if I remember correctly, used a temporary field.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer