I have game server tables in the same database as joomla tables. I am using joomla user credentials to login ingame, but for that I have to sync joomla username and password to game tables anytime joomla user updates their credentials. I also must encrypt the password using sha1 before storing it. I am using auto actions plugin for that. onNewPassword to update password when user goes Forgot login. onAfterUserUpdate when user changes their password in profile settings. onFirstLogin to store user credentials for the first time. Using auto actions to run queries sounds nice, but then I don’t know how to encrypt the password before storing it. To run php code, I am not sure how to use joomla database inside auto actions plugin. I don’t want to create a new database connection using hostname, database, username and password. I want to use existing joomla DB connection. Please advice 🙂
You can use Joomla's API directly in your Code action PHP. You don't need to manually establish database connections to Joomla. You can also use CBs API as well. Below is an example of running a query with CBs API.
That's all there is to it. Your query will run using Joomla database connection as our API just calls Joomla's own API. If using Joomla API keep in mind this is inline PHP you can't specify "use" statements (unless you opt to just include a php file) so you need to use the full PHP namespace path.
Kyle (Krileon) Community Builder Team Member Before posting on forums:
Read FAQ thoroughly
+
Read our Documentation
+
Search the forums CB links:
Documentation
-
Localization
-
CB Quickstart
-
CB Paid Subscriptions
-
Add-Ons
-
Forge
-- If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
-- If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please
send me a private message
with your thread and will reply when possible!
-- Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
-- My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.