SimpleLogger() – _initiator – Not Working
-
Hi There,
I hope you are doing well! I was trying to log some custom events using SimpleLogger() and had some issues with the _initiator, could you help with that?
I want to log events from specific users after receiving a webhook. If I log it directly, the initiator is empty/”other” or my admin user.
SimpleLogger()->info(
'User ' . $user->user_email . ' purchased ' . $product . ' successfully for $' . $amount_total,
[
'username' => $user->user_login,
'category' => 'payments',
]
);I checked the documentation here which pointed me to “_initiator”. I saw that a class is called for this, particular of notice to us: “Simple_History\Log_Initiators::::WP_USER”
This seems to return the following string:$user->user_login ($user->user_email)But if add the same to the logger, it silently fails without anything in the debug log either. I also tried adding “_user_id”, “_user_login”, “_user_email” which exhibit the same behaviour.
SimpleLogger()->info(
'User ' . $user->user_email . ' purchased ' . $product . ' successfully for $' . $amount_total,
[
'username' => $user->user_login,
'category' => 'payments',
'_initiator' => $user->user_login . ' (' . $user->user_email . ')'
]
);I suppose we can include the plugin file directly and then call the method but I don’t think it should matter much at least for testing.
I would really appreciate if you could help out with this. Thanks a lot!
The topic ‘SimpleLogger() – _initiator – Not Working’ is closed to new replies.