The SSI Import Tool provides WordPress filters that allow you to add custom SQL conditions to control which records are updated or deleted during imports.
Table of Contents
Update Filter: ssi_filter_updates_posts
Controls which posts get updated during the import process.
Hook: ssi_filter_updates
Parameters:
$where_condition
(string) – Initial WHERE condition (empty by default)$import_id
(int) – Current import ID
Table aliases available
p
– Alias for{$wpdb->posts}
table- import – Alias for the import batch table
{$this->table_names['batch']}
Example Code
add_filter('ssi_filter_updates', function($where_condition, $import_id) {
// Add your custom SQL condition
$where_condition .= " AND p.post_status = 'publish'";
return $where_condition;
}, 10, 2);
Update Postmeta Filter: ssi_filter_updates_postmeta
Controls which postmeta records get updated during the import process.
Hook: ssi_filter_updates_postmeta
Parameters:
$where_condition
(string) – Initial WHERE condition (empty by default)$import_id
(int) – Current import ID
Table aliases available
pm
– Alias for wp_postmeta table- import – Alias for the import batch table
{$this->table_names['batch']}
Example Code
add_filter('ssi_filter_updates_postmeta', function($where_condition, $import_id) {
// Add your custom SQL condition
$where_condition .= " AND pm.post_id IN (SELECT ID FROM wp_posts WHERE post_status = 'publish')";
return $where_condition;
}, 10, 2);
Delete Filter: ssi_filter_deletes
Controls which posts get deleted when they’re missing from the current import batch.
Hook: ssi_filter_deletes
Parameters:
$where_condition
(string) – Initial WHERE condition (empty by default)$import_id
(int) – Current import ID
Table aliases available
pm
– Alias forwp_postmeta
tableimport
– Alias for the import batch table created in the load-csv stage
Example Code
add_filter('ssi_filter_deletes', function($where_condition, $import_id) {
// Add your custom SQL condition
$where_condition .= " AND pm.post_id NOT IN (SELECT post_id FROM wp_protected_posts)";
return $where_condition;
}, 10, 2);
Best Practices
- Always prefix conditions with AND – The filters expect additional conditions, not replacements
- Always append to the existing where-condition – Super Speedy Imports makes use of these filters too for certain scenarios, so always append to the
$where_condition
- Use proper table aliases – Reference the correct aliases (p, pm, import) in your conditions and make sure they actually are available for the relevant filter
- Sanitize inputs – Use
$wpdb->prepare()
for any dynamic values - Test on staging – if you see errors, it should output the offending SQL too so you can fix it before putting this on live
- Consider performance – Super Speedy Imports is lightning fast, if it slows down because of your crappy SQL, it’s your fault!