Passing values between hooks - is it possible?

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
KSan
AppGini Super Hero
AppGini Super Hero
Posts: 252
Joined: 2013-01-08 20:17

Passing values between hooks - is it possible?

Post by KSan » 2013-01-08 20:21

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!

User avatar
a.gneady
Site Admin
Posts: 1281
Joined: 2012-09-27 14:46
Contact:

Re: Passing values between hooks - is it possible?

Post by a.gneady » 2013-01-08 21:23

Hi Kerem,

Welcome to the new forum :)

Try this:

Code: Select all

$GLOBAL['foo'] = 'bar';
And you can retrieve it later on anywhere else:

Code: Select all

echo $GLOBAL['foo'];
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
:idea: 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.

KSan
AppGini Super Hero
AppGini Super Hero
Posts: 252
Joined: 2013-01-08 20:17

Re: Passing values between hooks - is it possible?

Post by KSan » 2013-01-08 22:16

Ahmad, thank you very much for your prompt response. This is great! Your help is most appreciated.

dro102886
Posts: 2
Joined: 2020-06-09 12:41

Re: Passing values between hooks - is it possible?

Post by dro102886 » 2020-06-16 21:11

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.

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Passing values between hooks - is it possible?

Post by pbottcher » 2020-06-20 10:28

Hi,

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.

dro102886
Posts: 2
Joined: 2020-06-09 12:41

Re: Passing values between hooks - is it possible?

Post by dro102886 » 2020-06-23 01:57

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)";
}

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Passing values between hooks - is it possible?

Post by pbottcher » 2020-06-23 19:45

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.
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.

Post Reply