I got a noob extension development question here. I’m trying to modify some data upon submission of an entry for. I want to take the data from one field that is being submitted, check if certain conditions exist, and then update another field. I’m able to get the extension set up fine, and I’m able to see the data I want to work with when I vardump it within the main extension function. I’m even able to modify it, run the query I want, and update the data I want. I can see the change is taking place when I vardump the values after I make the modification.
But, how do I return the data so that it actual changes? I’ve tried several versions of “return” to no avail.
Bonus points:
From what I’ve described above, which of the hooks below do I want to be using?
function publish_form_entry_data($row)
{
}
And, in this extension hook, if I wanted to modify a value from the $meta AND the $data arrays, could I return both of those values in a modified form or can I only return one of those arrays?
function entry_submission_absolute_end($entry_id, $meta, $data)
{
}
If you could let me know what I’m missing, I’d appreciate it. I’m probably misunderstanding some fundamental element here. Cheers.
Hey Arvinsim. I finally did figure out how to do this. I don’t remember the exact details but I don’t believe it was possible to modify the data in the way I was describing above. I ended up grabbing the entry_id from one of the hooks and then wrote a separate query and just interfaced with the database directly to update the data.
Have you tried looking at the source from where the hook is called? In the api for channel entries, the hook is called with $this->data if you want to manipulate said data, have you tried using a reference?
function my_hook_catch( &$string, $foo='')
{
$foo = 'passed by value';
$string .= 'passed by reference';
}
$str = 'This is a string, ';
my_hook_catch($str);
echo $str;
// outputs 'This is a string, passed by reference'
// example 2 on http://php.net/manual/en/functions.arguments.php
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.