Manipulating the data variable in hooks

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
bdurfee
Veteran Member
Posts: 32
Joined: 2013-02-07 17:44

Manipulating the data variable in hooks

Post by bdurfee » 2013-10-25 19:04

I have a table in which the Detail View hides two of the fields from the user. However, I need specific information to be inserted into those fields when the user inserts a record. How do I add two more variables to the data array before the insert using the hook?

I tried this:

Code: Select all

function userinputtable_before_insert(&$data, $memberInfo, &$args)
	$uid = $memberInfo['username'];
	$data['userid'] = $uid;
	$data['site'] = 'RGN';
	
	return TRUE;
}
It doesn't work. Those two fields (userid, site) stay empty.


What is the correct way to add additional keys to the data array?
What is the correct way to change the data of keys stored the data array?

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

Re: Manipulating the data variable in hooks

Post by a.gneady » 2013-10-26 02:18

Try changing them through an explicit UPDATE statement in the userinputtable_after_insert() hook rather than userinputtable_before_insert()
: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.

Post Reply