Plugin Hook for Bulk Save?
3 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: July 29, 2014 (RSS)
By Perchpole - July 24, 2014
Hello, All -
I recently added a simple plugin to a site to send out user emails. It fires when a user account is saved using the record_postsave hook.
I also use the inlineEditing plugin but when I use this to save multiple user records, the email plugin does not fire.
Clearly I need to add a new hook...
:0/
Perch
By gregThomas - July 29, 2014
Hi Perch,
The problem is that the inlineEditing plugin doesn't contain a plugin hook to access after the record is saved, but its actually fairly simple to add the record_postsave hook.
If you go to line 54, you should see the following code:
$query = "UPDATE {$TABLE_PREFIX}{$tableName} SET ";
for ( $i=0; $i<count($q); $i++ ) {
$query .= $q[$i];
if ( $i+1 < count($q) ) $query .= ',';
}
$query .= " WHERE num='" . mysql_escape($num) . "'";
mysql_query( $query ) or die( 'Could not execute bulk update: ' . mysql_error() );
Then just add the following lines:
$query = "UPDATE {$TABLE_PREFIX}{$tableName} SET ";
for ( $i=0; $i<count($q); $i++ ) {
$query .= $q[$i];
if ( $i+1 < count($q) ) $query .= ',';
}
$query .= " WHERE num='" . mysql_escape($num) . "'";
$oldRecord = mysql_get($tableName, $num);
mysql_query( $query ) or die( 'Could not execute bulk update: ' . mysql_error() );
doAction('record_postsave', $tableName, false, $oldRecord, $num);
Adding these lines will make the inlineEditing plugin fire the record_postsave hook for each record that needs updating, and send it the record before it was edited in the $oldRecord variable.
These are custom changes, so we can't provide any official support for them.
Thanks!
Greg
PHP Programmer - interactivetools.com