Passing values between hooks - is it possible?
Passing values between hooks - is it possible?
Just wondering if there is a way to hold values in global variables and pass them as parameters between various hooks? If not I could add a table to my db to hold various values I want to bounce around and update it in one hook and read it in another hook so no biggie but I'd like to do this the proper way if there is a more elegant option. Thanks much!
Re: Passing values between hooks - is it possible?
Hi Kerem,
Welcome to the new forum
Try this:
And you can retrieve it later on anywhere else:
Please beware that this variable will be available only for the length of the request. Once the output has been sent to the user, the stored value will be gone. If you want to persist the variable, you should use $_SESSION rather than $GLOBAL
Welcome to the new forum
Try this:
Code: Select all
$GLOBAL['foo'] = 'bar';
Code: Select all
echo $GLOBAL['foo'];
AppGini plugins to add more power to your apps:
- DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
- Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
- Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.
Re: Passing values between hooks - is it possible?
Ahmad, thank you very much for your prompt response. This is great! Your help is most appreciated.
Re: Passing values between hooks - is it possible?
I have two tables New_Activation and Inventory. Is it possible to create a New_Activation record and once the Completed radio button is selected this information can be sent to the Inventory table as a record? Here is what I see on the hooks New_Activation folder:
function New_Activation_after_update($data, $memberInfo, &$args) {
return TRUE;
}
How should the code looked like to do this? I need to submit data here (New_Activation) and for it to appear in Inventory.
function New_Activation_after_update($data, $memberInfo, &$args) {
return TRUE;
}
How should the code looked like to do this? I need to submit data here (New_Activation) and for it to appear in Inventory.
Re: Passing values between hooks - is it possible?
Hi,
why dont you just use a SQL statement to put the corresponding data in your inventory table?
why dont you just use a SQL statement to put the corresponding data in your inventory table?
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: Passing values between hooks - is it possible?
Hi pböttcher,
Thank you for your reply. I do not know how to code and try to search online how to write it and for this I have tried the following and it does not do what I need as it does not update the 'Inventory' table.
function New_Activation_after_update($data, $memberInfo, &$args) {
SQL> "INSERT_INTO (Inventory.php)(Carrier, First_Name, Last_Name, Device_Type, Primary_Service_Plan, Add_On_Features, Wireless_Number)";
}
Thank you for your reply. I do not know how to code and try to search online how to write it and for this I have tried the following and it does not do what I need as it does not update the 'Inventory' table.
function New_Activation_after_update($data, $memberInfo, &$args) {
SQL> "INSERT_INTO (Inventory.php)(Carrier, First_Name, Last_Name, Device_Type, Primary_Service_Plan, Add_On_Features, Wireless_Number)";
}
Re: Passing values between hooks - is it possible?
Hi,
without having more information it is almost impossible to help. Have a look at the sql syntax.
You can use the sql or sqlvalue calls from appGini to realise your request.
From the hook you can access the $data variable which holds the data passed through the form upon submit.
without having more information it is almost impossible to help. Have a look at the sql syntax.
You can use the sql or sqlvalue calls from appGini to realise your request.
From the hook you can access the $data variable which holds the data passed through the form upon submit.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.