Feb 28th, 2012, 9:17 AM
Hi Ben,
This is very usefull, however I would like to ask if it's possible to do the same with field 'company_name' that is located in a different table (account_settings). I tried to create a hook rule for that but doesn't work.
This is very usefull, however I would like to ask if it's possible to do the same with field 'company_name' that is located in a different table (account_settings). I tried to create a hook rule for that but doesn't work.
(Feb 24th, 2012, 6:40 PM)Ben Wrote: Hi kokorase,
Here's how to log the name of the client who created the submissions.
1. Install the Hooks Manager module:
http://modules.formtools.org/hooks_manager/
2. In your form, create a new field called something like "Created By"; set it to a textbox, with database size "Medium" (256 chars), and give it database column name "created_by". All this is done on the Edit Form -> Fields tab.
3. Go to the Hooks Manager module and create a new rule with the following info:
Rule Name: "Created By"
Priority: 50
Hook Type: Code Hook
Code Hook: ft_create_blank_submission, end
PHP Code:
PHP Code:global $g_table_prefix;
$name = "{$_SESSION["ft"]["account"]["first_name"]} {$_SESSION["ft"]["account"]["last_name"]}";
$name = ft_sanitize($name);
mysql_query("UPDATE {$g_table_prefix}form_{$form_id} SET created_by = '$name' WHERE submission_id = $new_submission_id");
And that's it! Now, whenever a client (or the admin, for that matter) creates a new submission through the Form Tools interface, it will pull the name of the account (first + last name) and store it in the new "created_by" database column.
To have that information show up in the interface, you'll need to add the field to one of your Views.
Hope this helps!
- Ben