Our Action Reference provides hooks that allow you to change how WP All Import processes data. After customizing the examples based on your needs, you can place them either in WP All Import's Function Editor or your theme's functions.php file.
Click Here for more information.
pmxi_saved_post
This action fires when WP All Import saves a post of any type. The post ID, the record's data from your file, and a boolean value showing if the post is being updated are provided.
Parameters
ParamTypeDescription$post_idintThe ID of the item (post/user/taxonomy) saved or updated.$xml_nodeSimpleXMLElementThe libxml resource of the current XML element.$is_updateboolReturns 0 for new item 1 for updated item.
Usage
function my_saved_post( $post_id, $xml_node, $is_update ) {
// Retrieve the import ID.
$import_id = ( isset( $_GET['id'] ) ? $_GET['id'] : ( isset( $_GET['import_id'] ) ? $_GET['import_id'] : 'new' ) );
// Only run for import 8.
if ( $import_id == '8' ) {
// Convert SimpleXml object to array for easier use.
$record = json_decode( json_encode( ( array ) $xml_node ), 1 );
// Do something.
}
}
add_action( 'pmxi_saved_post', 'my_saved_post', 10, 3 );
Search the docs for pmxi_saved_post to see real-world code snippets that use this filter.
pmxi_before_xml_import
This action fires before any records are imported. It's used to call code that validates the import file or other code that needs to run at the start. It's called regardless of import file type used.
Parameters
ParamTypeDescription$import_idintThe ID of the import that's about to run.
Usage
function before_xml_import( $import_id ) {
// Only Run for import ID 5.
if ($import_id == 5) {
}
}
add_action('pmxi_before_xml_import', 'before_xml_import', 10, 1);
Search the docs for pmxi_before_xml_import to see real-world code snippets that use this filter.
pmxi_after_xml_import
This action fires after at the end of each import. The import object contains the values configured for the import and statistics for the last run.
Parameters
ParamTypeDescription$import_idintThe ID of the import that's about to run.$importobjectThe import object.
Usage
function after_xml_import( $import_id, $import ) {
// Only run if import ID is 5.
if ($import_id == 5) { // Do something. }
}
add_action( 'pmxi_after_xml_import', 'after_xml_import', 10, 2 );
Search the docs for pmxi_after_xml_import to see real-world code snippets that use this filter.
pmxi_update_post_meta
This action fires when WP All Import creates or updates post meta (custom fields). The post ID, field name, and field value are provided.
Parameters
ParamTypeDescription$post_idintThe ID of the imported item.$meta_keystring The name/key of the field that's being saved. $meta_valuemixed The value imported into the field.
Usage
function my_update_post_meta( $post_id, $meta_key, $meta_value) {
// Do something.
}
add_action( 'pmxi_update_post_meta', 'my_update_post_meta', 10, 3 );
Search the docs for pmxi_update_post_meta to see real-world code snippets that use this filter.
pmxi_gallery_image
This action fires each time an image is imported. It provides the post ID, image attachment ID, and image filepath as parameters. Whether or not existing images are deleted before new ones are imported is also indicated.
Parameters
ParamTypeDescription$post_idintThe ID of the imported item.$att_idintThe ID of the image that was imported.$filepathstringThe local file path to the full size image.$is_keep_existing_imagesbool/emptyReturns 1 if keeping existing images. Always cast as empty in the function arguments.
Usage
function wpai_image_imported( $post_id, $att_id, $filepath, $is_keep_existing_images = '' ) {
// Do something.
}
add_action( 'pmxi_gallery_image', 'wpai_image_imported', 10, 4 );
Search the docs for pmxi_gallery_image to see real-world code snippets that use this filter.
pmxi_attachment_uploaded
This action fires when an attachment is uploaded. It provides the post ID, attachment ID, and attachment file path. If you need to work with images use pmxi_gallery_image.
Parameters
ParamTypeDescription$post_idintThe post ID that's being imported.$att_idintThe attachment ID.$filepathstringThe full path to the file: C:pathtowordpresswp-contentuploads20105filename.png
Usage
function my_attachment_uploaded($pid, $attid, $filepath){
$attachment = get_post($attid);
// Do something with $attachment.
}add_action('pmxi_attachment_uploaded', 'my_attachment_uploaded', 10, 3);
Search the docs for pmxi_attachment_uploaded to see real-world code snippets that use this filter.
wp_all_import_is_post_to_update
This filter is used to determine if a post should be updated or skipped. It takes the post ID and, optionally, an array of XML nodes. The returned value should be either true to update the post or false to skip it.
Parameters
ParamTypeDescription$continuebooltrue to update, false to skip.$post_idintThe Post ID that's about to be updated.$xml_nodearrayAn array containing the data for the current import record.$import_idintThe ID of the import that's running.
Usage
function my_is_post_to_update( $continue, $post_id, $xml_node, $import_id ) {
// Run this code on a specific import
if ($import_id === 5) {
// Do something to decide if this post should update
if ( ... ) {
return true;
}
// Don't update this post
return false;
}
}
add_filter( 'wp_all_import_is_post_to_update', 'my_is_post_to_update', 10, 4 );
Search the docs for wp_all_import_is_post_to_update to see real-world code snippets that use this filter.
pmxi_acf_custom_field
This filter allows the modification of ACF field values. Only fields set to be updated or created during the import will fire this hook.
Parameters
ParamTypeDescription$valuemixedThe value being imported to the ACF field.$post_idintThe Post ID that's being imported.$namestringThe ACF field name.
Usage
function wp_all_import_pmxi_acf_custom_field( $value, $pid, $name ) {
// Code here.
}add_filter( 'pmxi_acf_custom_field', 'wp_all_import_pmxi_acf_custom_field', 10, 3 );
Search the docs for pmxi_acf_custom_field to see real-world code snippets that use this filter.
pmxi_after_post_import
This action fires after each imported post. If you need post IDs you should use pmxi_saved_post.
Parameters
ParamTypeDescription$import_idintThe import ID that's running.
Usage
function my_after_post_import($import_id)
{
// Only run for import ID 5.
if ($import_id === 5) { // Do something.
}
}
add_action('pmxi_after_post_import', 'my_after_post_import', 10, 1);
Search the docs for pmxi_after_post_import to see real-world code snippets that use this filter.
pmxi_article_data
This filter allows updating core post fields before each post is imported. When updating, $post_to_update contains the current post's WP_Post object. The current file record's data is in $current_xml_node.
Parameters
ParamTypeDescription$articleDataarrayCurrent article data.$importobjectThe import object.$post_to_updateobjectPost object for the post that's being updated.$current_xml_nodearrayParsed data for the current import record.
Here are the fields available for modification in the $articleData array:
array(15) { ["post_type"]=>string ["post_status"]=>string ["comment_status"]=>string ["ping_status"]=>string ["post_title"]=>string ["post_excerpt"]=>string ["post_name"]=>string ["post_content"]=>string ["post_date"]=>string ["post_date_gmt"]=>string ["post_author"]=>int ["menu_order"]=>int ["post_parent"]=>int ["page_template"]=>string ["ID"]=>string }
Usage
function my_pmxi_article_data( $articleData, $import, $post_to_update, $current_xml_node ) {
// Do something with the article data.
return $articleData;
}
add_filter('pmxi_article_data', 'my_pmxi_article_data', 10, 4);
Search the docs for pmxi_article_data to see real-world code snippets that use this filter.
pmxi_before_delete_post
This action fires just before WP All Import deletes a post. The post ID and import object are provided as parameters.
Parameters
ParamTypeDescription$post_idintThe post ID that's about to be deleted.$importobjectThe import object.
Usage
function before_delete_post( $post_id, $import ) {
// do something before post is deleted
}
add_action('pmxi_before_delete_post', 'before_delete_post', 10, 2);
Search the docs for pmxi_before_delete_post to see real-world code snippets that use this filter.
pmxi_custom_field
This filter first before a custom field's value is saved. If the field is being updated the $original_value is provided. The $value is provided and must be returned. The field's name, $key, and the post being updated, $post_id, are available.
Parameters
ParamTypeDescription$valuestringThe value being imported into the custom field.$post_idintThe post ID.$keystringThe custom field key.$original_valuestringOriginal, unserialized, value.$existing_meta_keysarrayExisting meta keys.$import_idintThe import ID that's running.
Usage
function my_custom_field( $value, $post_id, $key, $original_value, $existing_meta_keys, $import_id ) {
// Only run for import ID 5.
if ($import_id === 5) {
// Only modify the 'myField' custom field for post 65.
if( $key == 'myField' && $post_id == 65 ){
// Do something.
}
}
// Return the value for the custom field.
return $value;
}
add_filter( 'pmxi_custom_field', 'my_custom_field', 10, 6 );
Search the docs for pmxi_custom_field to see real-world code snippets that use this filter.
pmxi_delete_post
This action fires just before posts are deleted at the end of an import when using the 'Delete products that are no longer present in your file' option. It allows performing actions on the posts immediately before they are deleted. The list of post IDs to be deleted and the import object are provided.
Parameters
ParamTypeDescription$idsarrayArray of post IDs that will be deleted.$importobjectThe import object.
Usage
function wpai_pmxi_delete_post( $ids = array(), $import ){
foreach( $ids as $pid ) {
// do something with post using ID - $pid
}
}
add_action( 'pmxi_delete_post', 'wpai_pmxi_delete_post', 10, 2 );
Search the docs for pmxi_delete_post to see real-world code snippets that use this filter.
pmxi_single_category
This filter fires before taxonomy terms are imported and can be used to filter them. An array containing the term information and the taxonomy name are provided.
Parameters
ParamTypeDescription$term_intoarrayArray with term information.$tax_namestringThe taxonomy name.
Here is the $term_into array:
Array
(
[name] => {string}
[parent] => {int or empty if none}
[assign] => {bool}
[is_mapping] => {1 if true, empty if false}
[hierarchy_level] => {int}
[max_hierarchy_level] => {int}
)
Usage
function wpai_pmxi_single_category( $term_into, $tax_name ) {
// Do something.
// Return the updated term information.
return $term_into;
}
add_filter( 'pmxi_single_category', 'wpai_pmxi_single_category', 10, 2 );
Search the docs for pmxi_single_category to see real-world code snippets that use this filter.
wp_all_import_attachments_uploads_dir
DescriptionCan be used to change the directory that imported attachments are saved to.
Parameters
ParamTypeDescription$uploadsarrayContains information related to the WordPress uploads path & URL.$articleDataarrayContains a list of data related to the post/user/taxonomy being imported.$current_xml_nodearrayArray of data for current import record.$import_idintThe import ID that's running.
Usage
add_filter( 'wp_all_import_attachments_uploads_dir', 'wpai_wp_all_import_attachments_uploads_dir', 10, 4 );
function wpai_wp_all_import_attachments_uploads_dir( $uploads, $articleData, $current_xml_node, $import_id ) {
return $uploads;
}
Search the docs for wp_all_import_attachments_uploads_dir to see real-world code snippets that use this hook.
wp_all_import_auto_create_csv_headers
DescriptionAuto generate headers, or use headers in file.
You cannot call this hook from WP All Import's Function Editor. It must be saved in a plugin or in your theme.
Parameters
ParamTypeDescription$create_headersboolAuto-generate headers? true / false.$import_idintThe import ID that's running.
Usage
add_filter( 'wp_all_import_auto_create_csv_headers', 'wpai_wp_all_import_auto_create_csv_headers', 10, 2 );
function wpai_wp_all_import_auto_create_csv_headers( $create_headers, $import_id ){
// Return true to auto-generate header, or false to use the header in the file.
return $create_headers;
}
Search the docs for wp_all_import_auto_create_csv_headers to see real-world code snippets that use this hook.
wp_all_import_copy_uploaded_file_into_files_folder
DescriptionReturn TRUE and WP All Import will copy uploaded import file into /wp-content/uploads/wpallimport/files folder.
Parameters
ParamTypeDescription$copy_uploaded_filesboolCopy file? true / false.
Usage
function wpai_wp_all_import_copy_uploaded_file_into_files_folder( $copy_uploaded_files ) {
return $copy_uploaded_files;
}
add_filter( 'wp_all_import_copy_uploaded_file_into_files_folder', 'wpai_wp_all_import_copy_uploaded_file_into_files_folder', 10, 1 );
Search the docs for wp_all_import_copy_uploaded_file_into_files_folder to see real-world code snippets that use this hook.
wp_all_import_curl_download_only
DescriptionForce WP All Import to download the feed on the first request (skips reading headers). Useful if feeds reject multiple pings/requests.
This code must be added in a plugin or your theme. It will not work in WP All Import's Function Editor.
Parameters
ParamTypeDescription$download_onlyboolOnly download via curl? true / false.
Usage
add_filter( 'wp_all_import_curl_download_only', 'wpai_wp_all_import_curl_download_only', 10, 1 );
function wpai_wp_all_import_curl_download_only( $download_only ){
return true;
}
Search the docs for wp_all_import_curl_download_only to see real-world code snippets that use this hook.
wp_all_import_feed_type
DescriptionCan be used to define the feed type (xml/csv/json/etc).
This code must be added in a plugin or your theme. It will not work in WP All Import's Function Editor.
Parameters
ParamTypeDescription$typestringThe feed type.$urlstringThe URL that's being imported.
Usage
add_filter( 'wp_all_import_feed_type', 'wpai_feed_type', 10, 2 );
function wpai_feed_type( $type, $url ){
// Check $url and return $type.
return $type;
}
Search the docs for wp_all_import_feed_type to see real-world code snippets that use this hook.
wp_all_import_get_image_from_gallery
DescriptionCalled after an existing image is found in the Media Library. Only works with the "Use images currently in Media Library" and "Use images currently uploaded in wp-content/uploads/wpallimport/files/" options.
Parameters
ParamTypeDescription$attachobjectThe existing image that will be attached.$image_namestringThe image name that will be imported.$targetDirstringThe directory that the image will be uploaded to.
Usage
add_filter( 'wp_all_import_get_image_from_gallery', 'wpai_wp_all_import_get_image_from_gallery', 10, 3 );
function wpai_wp_all_import_get_image_from_gallery( $attach, $image_name, $targetDir ) {
/**
* do something with found attachment
*/
return $attach; // if attach === false the image will be downloaded
}
Search the docs for wp_all_import_get_image_from_gallery to see real-world code snippets that use this hook.
wp_all_import_handle_upload
DescriptionFilters the data array for attachments & images uploaded through WP All Import.
Parameters
ParamTypeDescription$filearrayContains the filepath, URL & filetype
Usage
add_filter( 'wp_all_import_handle_upload', 'wpai_wp_all_import_handle_upload', 10, 1 );
function wpai_wp_all_import_handle_upload( $file ){
// Handle & return $file here.
}
Search the docs for wp_all_import_handle_upload to see real-world code snippets that use this hook.
wp_all_import_image_filename
DescriptionCan be used to set a custom filename for an imported image.
Parameters
ParamTypeDescription$filenamestringThe filename as created by the import.$img_titlestringFrom "SEO and advanced options". Will always be blank for ACF fields.$img_captionstringFrom "SEO and advanced options". Will always be blank for ACF fields.$img_altstringFrom "SEO and advanced options". Will always be blank for ACF fields.$articleDataarrayArray of current import item data.$import_idintThe import ID.$img_urlstringThe image URL.
Usage
function wpai_image_filename( $filename = '', $img_title = '', $img_caption = '', $img_alt = '', $articleData = '', $import_id = '', $img_url = '' ) {
// Your code
return $filename;
}
add_filter( 'wp_all_import_image_filename', 'wpai_image_filename', 10, 7 );
Search the docs for wp_all_import_image_filename to see real-world code snippets that use this hook.
wp_all_import_images_uploads_dir
DescriptionCan be used to set a custom path in which images (as well as media intended for ACF fields) are uploaded. Only applies to media uploaded via WP All Import.
Parameters
ParamTypeDescription$uploadsarrayContains information related to the WordPress uploads path & URL$articleDataarrayContains a list of data related to the post/user/taxonomy being imported$current_xml_nodearrayContains a list of nodes within the current import record$import_idintContains the ID of the import.
Usage
add_filter( 'wp_all_import_images_uploads_dir', 'wpai_wp_all_import_images_uploads_dir', 10, 4 );
function wpai_wp_all_import_images_uploads_dir( $uploads, $articleData, $current_xml_node, $import_id ) {
// Do something with code here.
return $uploads;
}
Search the docs for wp_all_import_images_uploads_dir to see real-world code snippets that use this hook.
wp_all_import_is_check_duplicates
DescriptionTurn duplicate checking on/off. If you turn it off, WP All Import will create duplicate items each re-run.
Parameters
ParamTypeDescription$is_check_duplicatesboolCheck for duplicates? true / false.$import_idintThe import ID.
Usage
add_filter( 'wp_all_import_is_check_duplicates', 'wpai_is_check_duplicates', 10, 2 );
function wpai_is_check_duplicates( $is_check_duplicates, $import_id ) {
// Cancel checking for duplicates if this is import ID 10.
return ( $import_id == 10 ) ? false : true;
}
Search the docs for wp_all_import_is_check_duplicates to see real-world code snippets that use this hook.
wp_all_import_is_php_allowed
DescriptionDetermine whether PHP functions in the import template will be executed.
Parameters
ParamTypeDescription$is_php_allowedboolExecute functions? true / false.
Usage
function wpai_wp_all_import_is_php_allowed( $is_php_allowed ) {
return $is_php_allowed;
}
add_filter( 'wp_all_import_is_php_allowed', 'wpai_wp_all_import_is_php_allowed', 10, 1 );
Search the docs for wp_all_import_is_php_allowed to see real-world code snippets that use this hook.
wp_all_import_is_post_to_create
DescriptionThis filter is used to determine if a post should be created or skipped. The returned value should be either true to create the post or false to skip it.
Parameters
ParamTypeDescription$continue_importboolCreate post? true / false.$dataarrayAn array holding values for the current record. If importing from XML, attributes can be accessed as SimpleXMLElement objects.$import_idintThe import ID.
Usage
function my_is_post_to_create( $continue_import, $data, $import_id ) {
// Unless you want this code to execute for every import, check the import id
// if ($import_id === 5) { ... }
return true;
}
add_filter( 'wp_all_import_is_post_to_create', 'my_is_post_to_create', 10, 3 );
Search the docs for wp_all_import_is_post_to_create to see real-world code snippets that use this hook.
wp_all_import_is_post_to_delete
DescriptionThis fires when a missing post is about to be deleted by an import.
Parameters
ParamTypeDescription$is_post_to_deleteboolDelete post? true / false.$post_idintThe post ID that's about to be deleted.$importobjectThe import object.
Usage
function my_is_post_to_delete( $is_post_to_delete, $post_id, $import ) {
// Unless you want this code to execute for every import, check the import id
// if ( $import->id == 5 ) { ... }
return true;
}
add_filter( 'wp_all_import_is_post_to_delete', 'my_is_post_to_delete', 10, 3 );
Search the docs for wp_all_import_is_post_to_delete to see real-world code snippets that use this hook.
wp_all_import_is_unlink_missing_posts
DescriptionUsed to completely remove the relationship between import and post from pmxi_posts database table.
Parameters
ParamTypeDescription$is_unlink_missingboolUnlink post? true / false.$import_idintThe import ID.$post_idintThe post ID.
Usage
add_filter( 'wp_all_import_is_unlink_missing_posts', 'wpai_wp_all_import_is_unlink_missing_posts', 10, 3 );
function wpai_wp_all_import_is_unlink_missing_posts( $is_unlink_missing, $import_id, $post_id ) {
// Do something with code here.
return $is_unlink_missing;
}
Search the docs for wp_all_import_is_unlink_missing_posts to see real-world code snippets that use this hook.
wp_all_import_multi_glue
DescriptionChange the delimiter used when querying multiple values with XPath (default is ", "). Learn about XPath queries here: XPath Queries.
Parameters
ParamTypeDescription$delimiterstringThe delimiter.
Usage
add_filter( 'wp_all_import_multi_glue', 'wpai_wp_all_import_multi_glue', 10, 1 );
function wpai_wp_all_import_multi_glue( $delimiter ) {
// change delimiter if you want.
// e.g.:
// $delimiter = '|';
return $delimiter;
}
Search the docs for wp_all_import_multi_glue to see real-world code snippets that use this hook.
wp_all_import_phpexcel_object
DescriptionAccess/modify the PHPExcel object and file path for the import file.
Parameters
ParamTypeDescription$PHPExcelobjectThe PHPExcel object.$xlsFilePathstringThe path to the import file.
Usage
add_filter( 'wp_all_import_phpexcel_object', 'wpai_wp_all_import_phpexcel_object', 10, 2 );
function wpai_wp_all_import_phpexcel_object( $PHPExcel, $xlsFilePath ) {
return $PHPExcel;
}
Search the docs for wp_all_import_phpexcel_object to see real-world code snippets that use this hook.
wp_all_import_search_image_by_wp_attached_file
DescriptionCan be used to stop WP All Import from looking for existing images via _wp_attached_file.
Parameters
ParamTypeDescription$is_search_by_wp_attached_fileboolLook in _wp_attached_file? true / false.
Usage
add_filter( 'wp_all_import_search_image_by_wp_attached_file', 'wpai_wp_all_import_search_image_by_wp_attached_file', 10, 1 );
function wpai_wp_all_import_search_image_by_wp_attached_file( $is_search_by_wp_attached_file ) {
// do something with code here
return $is_search_by_wp_attached_file;
}
Search the docs for wp_all_import_search_image_by_wp_attached_file to see real-world code snippets that use this hook.
wp_all_import_set_post_terms
DescriptionCalled when WP All Import is setting the post taxonomy terms.
Parameters
ParamTypeDescription$term_taxonomy_idsarrayArray of taxonomy IDs.$tx_namestringThe name of the taxonomy.$pidintThe post ID.$import_idintThe import ID.
Usage
add_filter( 'wp_all_import_set_post_terms', 'wpai_wp_all_import_set_post_terms', 10, 4 );
function wpai_wp_all_import_set_post_terms( $term_taxonomy_ids, $tx_name, $pid, $import_id ) {
// Code here.
return $term_taxonomy_ids;
}
Search the docs for wp_all_import_set_post_terms to see real-world code snippets that use this hook.
wp_all_import_skip_x_csv_rows
DescriptionSpecifies the amount of rows to be skipped. You must use this hook in a plugin or your theme, not in WP All Import's Function Editor.
Parameters
ParamTypeDescription$skip_rowsbool/intReturn false to not skip rows. Return integer to specify how many rows to skip.$import_idintThe import ID.
Usage
add_filter( 'wp_all_import_skip_x_csv_rows', 'wpai_skip_rows', 10, 2 );
function wpai_skip_rows( $skip_rows, $import_id ) {
// Handle & return $skip_rows here.
}
Search the docs for wp_all_import_skip_x_csv_rows to see real-world code snippets that use this hook.
wp_all_import_specified_records
DescriptionUse this to override the specified records to be imported. It's a comma separated list of ints or int ranges. e.g. "1-7,10,15-20". The integers represent the position in the data file.
Parameters
ParamTypeDescription$specified_recordsstringThe current value from the "Import only specified records" option.$import_idintThe import ID.$root_nodes???
Usage
function my_specified_records( $specified_records, $import_id, $root_nodes ) {
// Unless you want this code to execute for every import, check the import id
// if ($import_id === 5) { ... }
// your code here
return $specified_records;
}
add_filter( 'wp_all_import_specified_records', 'my_specified_records', 10, 3 );
Search the docs for wp_all_import_specified_records to see real-world code snippets that use this hook.
wp_all_import_use_wp_set_object_terms
DescriptionForce WP All Import to use the wp_set_object_terms() WordPress function. Using this function is a bit slower, but it's sometimes necessary for compatibility with certain themes and plugins.
Parameters
ParamTypeDescription$use_wp_set_object_termsboolReturn true to use WordPress function wp_set_object_terms(). Return false to use pure SQL.$tx_namestringThe taxonomy name.
Usage
function wpai_wp_all_import_use_wp_set_object_terms( $use_wp_set_object_terms, $tx_name ) {
return $use_wp_set_object_terms;
}
add_filter( 'wp_all_import_use_wp_set_object_terms', 'wpai_wp_all_import_use_wp_set_object_terms', 10, 2 );
Search the docs for wp_all_import_use_wp_set_object_terms to see real-world code snippets that use this hook.
wpallimport_after_images_import
DescriptionCalled after the images section of the import is processed, but only when the "Keep images currently in Media Library" option is enabled.
Parameters
ParamTypeDescription$post_idintThe post ID.$gallery_attachment_idsarrayAn array of the images that were imported to the post.$missing_imagesarrayAn array of the images that were missing, based on previous imports.
Usage
function soflyy_img_import( $post_id, $gallery_attachment_ids, $missing_images ) {
// do something
}
add_action( 'wpallimport_after_images_import', 'soflyy_img_import', 10, 3 );
Search the docs for wpallimport_after_images_import to see real-world code snippets that use this hook.
wpallimport_xml_row
DescriptionAllows reading or modification of the data record before importing. All file types (CSV/JSON/XLS/XLSX/TXT/etc) are converted to XML, so this hook works with all of them.
Please note that XML nodes generated by this hook can't be used in "FOREACH" ACF Repeater fields.
Parameters
ParamTypeDescription$xml_nodelibxml resourceSimpleXMLElement containing the current records data.
Usage
function wpai_xml_row( $xml_node ) {
// Modify simpleXML object as needed
return $xml_node;
}
add_filter( 'wpallimport_xml_row', 'wpai_xml_row', 10, 1 );
Search the docs for wpallimport_xml_row to see real-world code snippets that use this hook.
pmxi_product_variation_saved
This action fires each time WP All Import save a product variation. The variation's ID is provided.
Parameters
ParamTypeDescription$variation_idintThe variation ID.
Usage
function wpai_wp_all_import_variation_imported( $variation_id ){
// Do something.
}
add_action( 'pmxi_product_variation_saved', 'wpai_wp_all_import_variation_imported', 10, 1 );
Search the docs for pmxi_product_variation_saved to see real-world code snippets that use this filter.
wp_all_import_get_prices_from_first_variation
DescriptionCan be used to set the parent product price to the price of the first variation in the case that WP All Import converts the product to a simple product.
Parameters
ParamTypeDescription$get_prices_from_first_variationboolSet parent product price to first variation price? true / false.$product_idintThe product ID.$import_idintThe import ID.
Usage
function wpai_wp_all_import_get_prices_from_first_variation( $get_prices_from_first_variation, $product_id, $import_id ) {
// do something
return $get_prices_from_first_variation;
}
add_filter( 'wp_all_import_get_prices_from_first_variation', 'wpai_wp_all_import_get_prices_from_first_variation', 10, 3 );
Search the docs for wp_all_import_get_prices_from_first_variation to see real-world code snippets that use this hook.
wp_all_import_make_product_simple
DescriptionCalled after a product is converted into a Simple Product by our WooCommerce Add-On. This only happens when the "Create products with no variations as simple product" option is enabled.
Parameters
ParamTypeDescription$product_idintThe product ID.$import_idintThe import ID.
Usage
function wpai_wp_all_import_make_product_simple( $product_id, $import_id ) {
// Code here.
}
add_action( 'wp_all_import_make_product_simple', 'wpai_wp_all_import_make_product_simple', 10, 2 );
Search the docs for wp_all_import_make_product_simple to see real-world code snippets that use this hook.
wp_all_import_product_attributes_delimiter
DescriptionModify the delimiter used to separate multiple attributes in the WooCommerce Add-On. Default is the pipe symbol "|".
Parameters
ParamTypeDescription$delimiterstringDefault is "|".$product_idintThe product ID.$import_idintThe import ID.
Usage
function wpai_wp_all_import_product_attributes_delimiter( $delimiter, $product_id, $import_id ) {
return $delimiter;
}
add_filter( 'wp_all_import_product_attributes_delimiter', 'wpai_wp_all_import_product_attributes_delimiter', 10, 3 );
Search the docs for wp_all_import_product_attributes_delimiter to see real-world code snippets that use this hook.
wp_all_import_variable_product_imported
DescriptionCalled when WP All Import saves a variable product
Parameters
ParamTypeDescription$product_idintThe product ID.
Usage
add_action( 'wp_all_import_variable_product_imported', 'wpai_wp_all_import_variable_product_imported', 10, 1 );
function wpai_wp_all_import_variable_product_imported( $post_parent ) {
// Code here.
}
Search the docs for wp_all_import_variable_product_imported to see real-world code snippets that use this hook.
wp_all_import_variation_any_attribute
DescriptionReturn true to set variation as "Any" in the case that multiple attribute values are present (e.g.: L|XL|XXL).
Parameters
ParamTypeDescription$variation_any_attributeboolSet variation to "Any"? true / false.$import_idintThe import ID.
Usage
function wpai_wp_all_import_variation_any_attribute( $variation_any_attribute, $import_id ) {
return $variation_any_attribute;
}
add_filter( 'wp_all_import_variation_any_attribute', 'wpai_wp_all_import_variation_any_attribute', 10, 2 );
Search the docs for wp_all_import_variation_any_attribute to see real-world code snippets that use this hook.
wp_all_import_variation_taxonomies
DescriptionCan be used to add taxonomies to WooCommerce product variations, which isn't supported by WooCommerce out of the box.
Parameters
ParamTypeDescription$taxonomiesarrayList of taxonomies.
Usage
add_filter( 'wp_all_import_variation_taxonomies', 'wpai_wp_all_import_variation_taxonomies', 10, 1 );
function wpai_wp_all_import_variation_taxonomies( $taxonomies ){
if ( ! in_array( 'my_taxonomy_name', $taxonomies ) ) $taxonomies[] = 'my_taxonomy_name';
return $taxonomies;
}
Search the docs for wp_all_import_variation_taxonomies to see real-world code snippets that use this hook.
pmxe_after_export
This action is used to run code after the export has completed. It provides the export ID and an object containing stats, settings, data, etc for the export.
Parameters
ParamTypeDescription$export_idintThe export ID.$exportObjobjectThe export object.
Usage
function wp_all_export_after_export( $export_id, $exportObj ) {
// Run for export 5 only
if ( $export_id === 5 ) {
// Do something
}
}
add_action( 'pmxe_after_export', 'wp_all_export_after_export', 10, 2 );
Search the docs for pmxe_after_export to see real-world code snippets that use this filter.
pmxe_after_iteration
This action fires after each iteration only when running via cron. It provides the export ID and an object containing stats, settings, data, etc for the export.
Parameters
ParamTypeDescription$export_idintThe export ID.$exportObjobjectThe export object.
Usage
function wpae_continue_cron( $export_id, $exportObj ) {
// Run this for a specific export
if ($export_id === 5) { // Do something }
} add_action( 'pmxe_after_iteration', 'wpae_continue_cron', 10, 2 );
Search the docs for pmxe_after_iteration to see real-world code snippets that use this filter.
pmxe_before_export
This action runs at the start of an export before any data is processed. It provides the export ID and must be called outside of the Function Editor - such as from your theme's functions.php file.
Parameters
ParamTypeDescription$export_idintThe export ID.
Usage
function wp_all_export_before_export( $export_id ) {
// Run this for a specific export.
if ($export_id === 5) { // Do something.
}
} add_action( 'pmxe_before_export', 'wp_all_export_before_export', 10, 1 );
Search the docs for pmxe_before_export to see real-world code snippets that use this filter.
pmxe_exported_post
This action fires after each record is saved to the export file. It provides the post ID and an object containing stats, settings, data, etc for the export.
Parameters
ParamTypeDescription$post_idintThe post ID.$exportObjobjectThe export object.
Usage
function wpae_pmxe_exported_post( $post_id, $exportObject ) { // Only run for a certain post.
if( $post_id == 55 ){ // Do something.
}}
add_action('pmxe_exported_post', 'wpae_pmxe_exported_post', 10, 2);
Search the docs for pmxe_exported_post to see real-world code snippets that use this filter.
pmxe_woo_field
This filter allows WooCommerce field values to be modified as they're exported. It provides the field's value, name, and the post ID. You must return the value as a string.
Parameters
ParamTypeDescription$valuemixedThe value of the field.$field_namestringThe field name.$pidintThe post ID.
Usage
function wp_all_export_woo_field( $value, $field_name, $pid ) { if( $field_name == '_a_field' ){
// Generate the new value
return $new_value; } else { return $value; }
}add_filter( 'pmxe_woo_field', 'wp_all_export_woo_field', 10, 3 );
Search the docs for pmxe_woo_field to see real-world code snippets that use this filter.
wp_all_export_additional_data
This filter only fires when Simple XML Feed exports run. It does nothing for any other export type. Any additional fields currently added will be in the $add_data parameter. The $options parameter contains the full export configuration. The export ID is provided in the last parameter.
Parameters
ParamTypeDescription$add_dataarrayAny additional data to add, empty by default.$optionsarrayExport options array containing the export's configuration.$export_idintID of the running export.
Usage
function wpae_additional_data( $add_data, $options, $export_id ) {
// Add data as needed.
// Return the updated data array.
return $add_data;
}
add_filter( 'wp_all_export_additional_data', 'wpae_additional_data', 10, 2 );
Search the docs for wp_all_export_additional_data to see real-world code snippets that use this filter.
wp_all_export_after_csv_line
This filter fires after each CSV line and provides the file resource handle so that additional characters can be added. The second parameter provides the export ID.
Parameters
ParamTypeDescription$streamfile system pointer resourceThe resource handle pointing to the export file.$export_idintThe export ID.
Usage
function wpae_wp_all_export_after_csv_line( $stream, $export_id ){
// Do something.
return $stream;
}
add_filter( 'wp_all_export_after_csv_line', 'wpae_wp_all_export_after_csv_line', 10, 2 );
Search the docs for wp_all_export_after_csv_line to see real-world code snippets that use this filter.
wp_all_export_config_options
This filter fires during exports and was specifically added to allow changing the max_execution_time and max_input_time values. The other options are listed below but should not be modified with the filter.
Parameters
ParamTypeDescription$optionsarrayExport configuration options.
Option array values:
Array
(
[info_api_url] => http://www.wpallimport.com
[scheduling_license] => {hashed string}
[scheduling_license_status] => {status string}
[dismiss] => 0
[dismiss_manage_top] => 0
[dismiss_manage_bottom] => 0
[cron_job_key] => {string}
[max_input_time] => -1
[max_execution_time] => -1
[secure] => 1
[license] => {hashed string}
[license_status] => {status string}
[zapier_api_key] => {string}
[zapier_invitation_url] =>
[zapier_invitation_url_received] =>
)
Usage
function wpai_wp_all_import_config_options( $options ) {
// Do something.
return $options;
}
add_filter( 'wp_all_export_config_options', 'wpai_wp_all_import_config_options', 10, 1 );
Search the docs for wp_all_export_config_options to see real-world code snippets that use this filter.
wp_all_export_csv_headers
DescriptionManipulate export file headers.
Parameters
ParamTypeDescription$headersarrayCurrent headers.$export_idintThe export ID.
Usage
add_filter( 'wp_all_export_csv_headers', 'wpae_wp_all_export_csv_headers', 10, 2 );
function wpae_wp_all_export_csv_headers( $headers, $export_id ) {
// Code here.
return $headers;
}
Search the docs for wp_all_export_csv_headers to see real-world code snippets that use this hook.
wp_all_export_csv_rows
DescriptionFilters the records to export. This is for CSV formatted exports only. See 'wp_all_export_xml_rows' for filtering XML exports.
Parameters
ParamTypeDescription$articlesarrayAn array of records for exporting. Each article is keyed by the column header name for that field.$optionsarrayThe export configuration options.$export_idintThe export ID.
Usage
function wp_all_export_csv_rows( $articles, $options, $export_id ) {
// Unless you want this code to execute for every export, be sure to check the export id
// if ($export_id == 5) { ...
// Loop through the array and unset() any entries you don't want exported
// foreach ($articles as $key => $article) {
// if ($article["Title"] == "Something") {
// unset($articles[$key]);
// }
// }
return $articles; // Return the array of records to export
}
add_filter( 'wp_all_export_csv_rows', 'wp_all_export_csv_rows', 10, 3 );
Search the docs for wp_all_export_csv_rows to see real-world code snippets that use this hook.
wp_all_export_export_file_name
DescriptionFilter to change the filename of the exported data file
Parameters
ParamTypeDescription$file_path stringThe file path, including the filename.$export_id intThe export ID.
Usage
function wpae_wp_all_export_export_file_name( $file_path, $export_id ){
// Unless you want your code to execute for every export, be sure to check the export id
// if ($export_id === 5) { ... }
return $file_path;
}
add_filter( 'wp_all_export_export_file_name', 'wpae_wp_all_export_export_file_name', 10, 2 );
Search the docs for wp_all_export_export_file_name to see real-world code snippets that use this hook.
wp_all_export_generate_bundle
DescriptionDetermine whether the bundle zip file should be generated.
Parameters
ParamTypeDescription$is_generate_bundle boolGenerate bundle? true / false.
Usage
add_filter( 'wp_all_export_generate_bundle', 'wpae_do_not_generate_bundle', 10, 1 );
function wpae_do_not_generate_bundle( $is_generate_bundle ) {
return $is_generate_bundle ;
}
Search the docs for wp_all_export_generate_bundle to see real-world code snippets that use this hook.
wp_all_export_implode_delimiter
DescriptionModify the implode delimiter for export fields. Default delimiter is the pipe symbol "|".
Parameters
ParamTypeDescription$implode_delimiterstringThe delimiter to be used. Default is "|".$export_idintThe export ID.
Usage
function wpae_wp_all_export_implode_delimiter( $implode_delimiter, $export_id ) {
// do something
return $implode_delimiter;
}
add_filter( 'wp_all_export_implode_delimiter', 'wpae_wp_all_export_implode_delimiter', 10, 2 );
Search the docs for wp_all_export_implode_delimiter to see real-world code snippets that use this hook.
wp_all_export_is_csv_headers_enabled
DescriptionCan be used to completely remove the CSV header.
Parameters
ParamTypeDescription$is_headers_enabled boolKeep headers? true / false.$export_idintThe export ID.
Usage
add_filter( 'wp_all_export_is_csv_headers_enabled', 'wpae_wp_all_export_is_csv_headers_enabled', 10, 2 );
function wpae_wp_all_export_is_csv_headers_enabled( $is_headers_enabled, $export_id ){
// return 'false' to remove the header.
return $is_headers_enabled;
}
Search the docs for wp_all_export_is_csv_headers_enabled to see real-world code snippets that use this hook.
wp_all_export_order_item
DescriptionFilters the items in a WooCommerce Order to export.
Parameters
ParamTypeDescription$is_export_recordboolInclude item in export? true / false.$product_idintThe product ID.$export_optionsarrayThe export options array.$export_idintThe export ID.
Usage
function filter_my_order_items ( $is_export_record, $product_id, $export_options, $export_id ) {
// Unless you want this to execute for every export you should check the id here:
// if ( $export_id === 5 ) {
// Your code here
return true;
}
add_filter( "wp_all_export_order_item", "filter_my_order_items", 10, 4 );
Search the docs for wp_all_export_order_item to see real-world code snippets that use this hook.
wp_all_export_pre_csv_headers
DescriptionAllows for CSV headers to be added above the default headers.
Parameters
ParamTypeDescription$preCsvHeadersbool / stringThe headers to add to the file. Default false.$export_idintThe export ID.
Usage
add_filter( 'wp_all_export_pre_csv_headers', 'export_add_headers', 10, 2 );
function export_add_headers ( $preCsvHeaders, $exportId ) {
// Modify & return $preCsvHeaders
return $preCsvHeaders;
}
Search the docs for wp_all_export_pre_csv_headers to see real-world code snippets that use this hook.
wp_all_export_product_variation_mode
DescriptionChoose whether to export parent products or just variations.
Parameters
ParamTypeDescription$exportVariationMode stringExport variation mode.$export_idintThe export ID.
Usage
add_filter( 'wp_all_export_product_variation_mode', 'export_only_variations', 10, 2 );
function export_only_variations( $exportVariationMode, $exportID ) {
return XmlExportEngine::VARIABLE_PRODUCTS_EXPORT_VARIATION; // Only export variations for variable products, don't export the parent products
}
Search the docs for wp_all_export_product_variation_mode to see real-world code snippets that use this hook.
wp_all_export_raw_prices
DescriptionCan be used to disable price formatting for WooCommerce exports.
Parameters
ParamTypeDescription$raw_pricesboolDisable price formatting? true / false.
Usage
add_filter( 'wp_all_export_raw_prices', 'my_disable_formatting', 10, 1 );
function my_disable_formatting( $raw_prices ) {
// do something
return $raw_prices;
}
Search the docs for wp_all_export_raw_prices to see real-world code snippets that use this hook.
wp_all_export_repeater_delimiter
DescriptionDefine the delimiter used for ACF Repeater fields. Default is comma.
Parameters
ParamTypeDescription$implode_delimiterstringThe delimiter to use. Default ",".$export_idintThe export ID.
Usage
add_filter( 'wp_all_export_repeater_delimiter', 'wpae_wp_all_export_repeater_delimiter', 10, 2 );
function wpae_wp_all_export_repeater_delimiter( $implode_delimiter, $export_id ) {
return $implode_delimiter;
}
Search the docs for wp_all_export_repeater_delimiter to see real-world code snippets that use this hook.
wp_all_export_use_csv_compliant_line_endings
DescriptionUse custom CSV writer when affected by https://bugs.php.net/bug.php?id=43225.
Parameters
ParamTypeDescription$use_compliant_endingsboolUse compliant endings? true / false.
Usage
add_filter( 'wp_all_export_csv_strategy', function( $csvStrategy ) {
return WpaeCsvCsvWriter::CSV_STRATEGY_CUSTOM;
}, 10, 1 );
add_filter( 'wp_all_export_use_csv_compliant_line_endings', function( $useCsvCompliantLineEndings ) {
return true;
}, 10, 1 );
Search the docs for wp_all_export_use_csv_compliant_line_endings to see real-world code snippets that use this hook.
wp_all_export_xml_rows
DescriptionFilter a single XML record for conditional export. See wp_all_export_csv_rows for CSV exports.
Parameters
ParamTypeDescription$is_export_recordboolInclude record in export? true / false.$recordobjectRecord object.$export_optionsarrayThe export options.$export_idintThe export ID.
Usage
function my_wp_all_export_xml_rows( $is_export_record, $record, $export_options, $export_id ) {
// Unless you want this code to execute for every export, be sure to check the export id
//
// if ( $export_id == 5 ) { ...
// Check $record object and return true to export or false to skip
return true;
}
add_filter( 'wp_all_export_xml_rows', 'my_wp_all_export_xml_rows', 10, 4 );
Search the docs for wp_all_export_xml_rows to see real-world code snippets that use this hook.
wp_all_export_zapier_response
DescriptionCan be used to manipulate the response sent to Zapier.
Parameters
ParamTypeDescription$responsearrayThe response to Zapier.
Usage
add_filter( 'wp_all_export_zapier_response', 'wpae_wp_all_export_zapier_response', 10, 1 );
function wpae_wp_all_export_zapier_response( $response ) {
// Code here.
return $response;
}
Search the docs for wp_all_export_zapier_response to see real-world code snippets that use this example.
pmxi_custom_types
This filter allows modifying the option shown in the post type dropdown on Step 1 of an import. The current list of types and the list being updated are available as parameters. The custom_types list is where you'd add a post type to the dropdown that doesn't otherwise appear. The hidden_post_types list allows removing items from the dropdown.
Parameters
ParamTypeDescription$custom_typesarrayThe list of post types that will be available.$typestringWhich type of list is being updated - custom_types or hidden_post_types
Usage
function wpai_custom_types( $custom_types ) {
// Modify the custom types to be shown on Step 1.
// Return the updated list.
return $custom_types;
}
add_filter( 'pmxi_custom_types', 'wpai_custom_types', 10, 1 );
Search the docs for pmxi_custom_types to see real-world code snippets that use this filter.
pmxi_visible_template_sections
This filter allows modifying what sections are shown on Step 3 and Manage Imports > Edit Import. It provides an array of sections set to show and the post type being imported.
Parameters
ParamTypeDescription$sectionsstring arrayThe sections to show on Step 3. Possible options:'caption', 'main', 'taxonomies', 'cf', 'featured', 'other', 'nested'$post_typestringThe post type being imported.
Usage
function show_addon_section_users_customers( $sections, $post_type ) {
// Do something for your post type.
if ( 'your_post_type' == $post_type )
// Do something.
return $sections;
}
add_filter( 'pmxi_visible_template_sections', 'show_addon_section_users_customers', 11, 2 );
Search the docs for pmxi_visible_template_sections to see real-world code snippets that use this filter.
wp_all_import_minimum_number_of_variations
DescriptionUse this hook to set the minimum number of variations a product can have before it's converted to a simple product by the "Create products with no variations as simple products" option.
Parameters
ParamTypeDescription$min_variationsintMinimum number of variations. Default 2.$product_idboolThe Product ID.$import_idstringThe Import ID.
Usage
add_filter( 'wp_all_import_minimum_number_of_variations', 'wpai_wp_all_import_minimum_number_of_variations', 10, 3 );function wpai_wp_all_import_minimum_number_of_variations( $min_number_of_variations, $pid, $import_id ) { return 1;}
Search the docs for wp_all_import_minimum_number_of_variations to see real-world code snippets that use this hook.
wpai_is_case_insensitive_taxonomy_mapping
DescriptionReturn true to make the mapping rules in the "Enable Mapping for Categories" section case insensitive. Added in WP All Import v4.7.0-beta-1.1.
Parameters
ParamTypeDescription$is_case_insensitiveboolDefaults to false.$tx_namestringThe taxonomy name.
Usage
add_filter( 'wpai_is_case_insensitive_taxonomy_mapping', 'my_is_case_insensitive_mapping', 10, 2 );
function my_is_case_insensitive_mapping( $is_case_insensitive, $tx_name ) {
// Return true to make it case insensitive
return $is_case_insensitive;
}
Search the docs for wpai_is_case_insensitive_taxonomy_mapping to see real-world code snippets that use this hook.
wp_all_import_post_skipped
DescriptionFires whenever an import record is SKIPPED.
Parameters
ParamTypeDescription$post_to_update_idintThe post ID, or 0 if there's no post.$import_idintThe import ID.$current_xml_nodearrayAn array with the current import record's data.
Usage
// Log all skips
add_action( 'wp_all_import_post_skipped', 'my_log_skips', 10, 3 );
function my_log_skips( $created, $import_id, $xml_data ) {
$uploads = wp_upload_dir();
$log_file_name = $uploads['basedir'] . '/' . $import_id . '_import_custom_log.txt';
if ( file_exists( $log_file_name ) ) {
$existing_data = file_get_contents( $log_file_name );
} else {
touch( $log_file_name );
$existing_data = '';
}
if ( $created == 0 ) {
$created = 'N/A';
}
if ( array_key_exists( 'sku', $xml_data ) && array_key_existS( 'title', $xml_data ) ) {
$existing_data .= '[ID: ' . $created . '] [SKU: ' . $xml_data['sku'] . '] [Title: ' . $xml_data['title'] . '] has been skipped.' . PHP_EOL;
file_put_contents( $log_file_name, $existing_data );
}
}
Search the docs for wp_all_import_post_skipped to see other real-world code snippets that use this hook.