Here are the Hooks Provided By WP All Import and WP All Export
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
Description
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
Param | Type | Description |
$post_id | int | The ID of the item (post/user/taxonomy) saved or updated. |
$xml_node | SimpleXMLElement | The libxml resource of the current XML element. |
$is_update | bool | Returns 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 = wp_all_import_get_import_id();
// 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
Description
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
Param | Type | Description |
$import_id | int | The 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) {
// Do something.
}
}
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
Description
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
Param | Type | Description |
$import_id | int | The ID of the import that's about to run. |
$import | object | The 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
Description
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
Param | Type | Description |
$post_id | int | The ID of the imported item. |
$meta_key | string | The name/key of the field that's being saved. |
$meta_value | mixed | 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
Description
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
Param | Type | Description |
$post_id | int | The ID of the imported item. |
$att_id | int | The ID of the image that was imported. |
$filepath | string | The local file path to the full size image. |
$is_keep_existing_images | bool/empty | Returns 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
Description
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
Param | Type | Description |
$post_id | int | The post ID that's being imported. |
$att_id | int | The attachment ID. |
$filepath | string | The 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
Description
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
Param | Type | Description |
$continue | bool | true to update, false to skip. |
$post_id | int | The Post ID that's about to be updated. |
$xml_node | array | An array containing the data for the current import record. |
$import_id | int | The 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
Description
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
Param | Type | Description |
$value | mixed | The value being imported to the ACF field. |
$post_id | int | The Post ID that's being imported. |
$name | string | The 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
Description
This action fires after each imported post. If you need post IDs you should use pmxi_saved_post
.
Parameters
Param | Type | Description |
$import_id | int | The 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
Description
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
Param | Type | Description |
$articleData | array | Current article data. |
$import | object | The import object. |
$post_to_update | object | Post object for the post that's being updated. |
$current_xml_node | array | Parsed 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
Description
This action fires just before WP All Import deletes a post. The post ID and import object are provided as parameters.
Parameters
Param | Type | Description |
$post_id | int | The post ID that's about to be deleted. |
$import | object | The 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
Description
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
Param | Type | Description |
$value | string | The value being imported into the custom field. |
$post_id | int | The post ID. |
$key | string | The custom field key. |
$original_value | string | Original, unserialized, value. |
$existing_meta_keys | array | Existing meta keys. |
$import_id | int | The 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
Description
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
Param | Type | Description |
$ids | array | Array of post IDs that will be deleted. |
$import | object | The 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
Description
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
Param | Type | Description |
$term_into | array | Array with term information. |
$tax_name | string | The 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
Description
Can be used to change the directory that imported attachments are saved to.
Parameters
Param | Type | Description |
$uploads | array | Contains information related to the WordPress uploads path & URL. |
$articleData | array | Contains a list of data related to the post/user/taxonomy being imported. |
$current_xml_node | array | Array of data for current import record. |
$import_id | int | The 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
Description
Auto 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
Param | Type | Description |
$create_headers | bool | Auto-generate headers? true / false. |
$import_id | int | The 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
Description
Return TRUE and WP All Import will copy uploaded import file into /wp-content/uploads/wpallimport/files folder.
Parameters
Param | Type | Description |
$copy_uploaded_files | bool | Copy 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
Description
Force 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
Param | Type | Description |
$download_only | bool | Only 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
Description
Can 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
Param | Type | Description |
$type | string | The feed type. |
$url | string | The 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
Description
Called 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
Param | Type | Description |
$attach | object | The existing image that will be attached. |
$image_name | string | The image name that will be imported. |
$targetDir | string | The 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
Description
Filters the data array for attachments & images uploaded through WP All Import.
Parameters
Param | Type | Description |
$file | array | Contains 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
Description
Can be used to set a custom filename for an imported image.
Parameters
Param | Type | Description |
$filename | string | The filename as created by the import. |
$img_title | string | From "SEO and advanced options". Will always be blank for ACF fields. |
$img_caption | string | From "SEO and advanced options". Will always be blank for ACF fields. |
$img_alt | string | From "SEO and advanced options". Will always be blank for ACF fields. |
$articleData | array | Array of current import item data. |
$import_id | int | The import ID. |
$img_url | string | The 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
Description
Can 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
Param | Type | Description |
$uploads | array | Contains information related to the WordPress uploads path & URL. |
$articleData | array | Contains a list of data related to the post/user/taxonomy being imported. |
$current_xml_node | array | Contains a list of nodes within the current import record. |
$import_id | int | Contains 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
Description
Turn duplicate checking on/off. If you turn it off, WP All Import will create duplicate items each re-run.
Parameters
Param | Type | Description |
$is_check_duplicates | bool | Check for duplicates? true / false. |
$import_id | int | The 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
Description
Determine whether PHP functions in the import template will be executed.
Parameters
Param | Type | Description |
$is_php_allowed | bool | Execute 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
Description
This 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
Param | Type | Description |
$continue_import | bool | Create post? true / false. |
$data | array | An array holding values for the current record. |
$import_id | int | The 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
Description
This fires when a missing post is about to be deleted by an import.
Parameters
Param | Type | Description |
$is_post_to_delete | bool | Delete post? true / false. |
$post_id | int | The post ID that's about to be deleted. |
$import | object | The 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
Description
Used to completely remove the relationship between import and post from pmxi_posts database table.
Parameters
Param | Type | Description |
$is_unlink_missing | bool | Unlink post? true / false. |
$import_id | int | The import ID. |
$post_id | int | The 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
Description
Change the delimiter used when querying multiple values with XPath (default is ", "). Learn about XPath queries here: XPath Queries.
Parameters
Param | Type | Description |
$delimiter | string | The 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
Description
Access/modify the PHPExcel object and file path for the import file.
Parameters
Param | Type | Description |
$PHPExcel | object | The PHPExcel object. |
$xlsFilePath | string | The 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
Description
Can be used to stop WP All Import from looking for existing images via _wp_attached_file.
Parameters
Param | Type | Description |
$is_search_by_wp_attached_file | bool | Look 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
Description
Called when WP All Import is setting the post taxonomy terms.
Parameters
Param | Type | Description |
$term_taxonomy_ids | array | Array of taxonomy IDs. |
$tx_name | string | The name of the taxonomy. |
$pid | int | The post ID. |
$import_id | int | The 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
Description
Specifies 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
Param | Type | Description |
$skip_rows | bool/int | Return false to not skip rows. Return integer to specify how many rows to skip. |
$import_id | int | The 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
Description
Use this to override the specified records to be imported that were defined in the Import only specified records option in the import settings. That option has to be enabled for this hook to fire. 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
Param | Type | Description |
$specified_records | string | The current value from the "Import only specified records" option. |
$import_id | int | The import ID. |
$root_nodes | array | Contains an array of simpleXML objects of nodes from the used import file. |
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
Description
Force 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
Param | Type | Description |
$use_wp_set_object_terms | bool | Return true to use WordPress function wp_set_object_terms(). Return false to use pure SQL. |
$tx_name | string | The 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
Description
Called after the images section of the import is processed, but only when the "Keep images currently in Media Library" option is enabled.
Parameters
Param | Type | Description |
$post_id | int | The post ID. |
$gallery_attachment_ids | array | An array of the images that were imported to the post. |
$missing_images | array | An 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
Description
Allows 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
Param | Type | Description |
$xml_node | libxml resource | SimpleXMLElement 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
Description
This action fires each time WP All Import save a product variation. The variation's ID is provided.
Parameters
Param | Type | Description |
$variation_id | int | The 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
Description
Can 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
Param | Type | Description |
$get_prices_from_first_variation | bool | Set parent product price to first variation price? true / false. |
$product_id | int | The product ID. |
$import_id | int | The 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
Description
Called 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
Param | Type | Description |
$product_id | int | The product ID. |
$import_id | int | The 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
Description
Modify the delimiter used to separate multiple attributes in the WooCommerce Add-On. Default is the pipe symbol "|".
Parameters
Param | Type | Description |
$delimiter | string | Default is "|". |
$product_id | int | The product ID. |
$import_id | int | The 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
Description
Called when WP All Import saves a variable product
Parameters
Param | Type | Description |
$product_id | int | The 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
Description
Return true to set variation as "Any" in the case that multiple attribute values are present (e.g.: L|XL|XXL).
Parameters
Param | Type | Description |
$variation_any_attribute | bool | Set variation to "Any"? true / false. |
$import_id | int | The 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
Description
Can be used to add taxonomies to WooCommerce product variations, which isn't supported by WooCommerce out of the box.
Parameters
Param | Type | Description |
$taxonomies | array | List 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
Description
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
Param | Type | Description |
$export_id | int | The export ID. |
$exportObj | object | The 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
Description
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
Param | Type | Description |
$export_id | int | The export ID. |
$exportObj | object | The 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
Description
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
Param | Type | Description |
$export_id | int | The 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
Description
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
Param | Type | Description |
$post_id | int | The post ID. |
$exportObj | object | The 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
Description
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
Param | Type | Description |
$value | mixed | The value of the field. |
$field_name | string | The field name. |
$pid | int | The 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
Description
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
Param | Type | Description |
$add_data | array | Any additional data to add, empty by default. |
$options | array | Export options array containing the export's configuration. |
$export_id | int | ID 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
Description
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
Param | Type | Description |
$stream | file system pointer resource | The resource handle pointing to the export file. |
$export_id | int | The 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
Description
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
Param | Type | Description |
$options | array | Export 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
Description
Manipulate export file headers.
Parameters
Param | Type | Description |
$headers | array | Current headers. |
$export_id | int | The 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
Description
Filters the records to export. This is for CSV formatted exports only. See 'wp_all_export_xml_rows' for filtering XML exports.
Parameters
Param | Type | Description |
$articles | array | An array of records for exporting. Each article is keyed by the column header name for that field. |
$options | array | The export configuration options. |
$export_id | int | The 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
Description
Filter to change the filename of the exported data file
Parameters
Param | Type | Description |
$file_path | string | The file path, including the filename. |
$export_id | int | The 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
Description
Determine whether the bundle zip file should be generated.
Parameters
Param | Type | Description |
$is_generate_bundle | bool | Generate 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
Description
Modify the implode delimiter for export fields. Default delimiter is the pipe symbol "|".
Parameters
Param | Type | Description |
$implode_delimiter | string | The delimiter to be used. Default is "|". |
$export_id | int | The 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
Description
Can be used to completely remove the CSV header.
Parameters
Param | Type | Description |
$is_headers_enabled | bool | Keep headers? true / false. |
$export_id | int | The 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
Description
Filters the items in a WooCommerce Order to export.
Parameters
Param | Type | Description |
$is_export_record | bool | Include item in export? true / false. |
$product_id | int | The product ID. |
$export_options | array | The export options array. |
$export_id | int | The 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
Description
Allows for CSV headers to be added above the default headers.
Parameters
Param | Type | Description |
$preCsvHeaders | bool / string | The headers to add to the file. Default false. |
$export_id | int | The 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
Description
Choose whether to export parent products or just variations.
Parameters
Param | Type | Description |
$exportVariationMode | string | Export variation mode. |
$export_id | int | The 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
Description
Can be used to disable price formatting for WooCommerce exports.
Parameters
Param | Type | Description |
$raw_prices | bool | Disable 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
Description
Define the delimiter used for ACF Repeater fields. Default is comma.
Parameters
Param | Type | Description |
$implode_delimiter | string | The delimiter to use. Default ",". |
$export_id | int | The 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
Description
Use custom CSV writer when affected by https://bugs.php.net/bug.php?id=43225.
Parameters
Param | Type | Description |
$use_compliant_endings | bool | Use compliant endings? true / false. |
Usage
add_filter( 'wp_all_export_csv_strategy', function( $csvStrategy ) {
return \Wpae\Csv\CsvWriter::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
Description
Filter a single XML record for conditional export. See wp_all_export_csv_rows for CSV exports.
Parameters
Param | Type | Description |
$is_export_record | bool | Include record in export? true / false. |
$record | object | Record object. |
$export_options | array | The export options. |
$export_id | int | The 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
Description
Can be used to manipulate the response sent to Zapier.
Parameters
Param | Type | Description |
$response | array | The 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
Description
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
Param | Type | Description |
$custom_types | array | The list of post types that will be available. |
$type | string | Which 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
Description
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
Param | Type | Description |
$sections | string array | The sections to show on Step 3. Possible options: 'caption', 'main', 'taxonomies', 'cf', 'featured', 'other', 'nested' |
$post_type | string | The 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
Description
Use 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
Param | Type | Description |
$min_variations | int | Minimum number of variations. Default 2. |
$product_id | bool | The Product ID. |
$import_id | string | The 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
Description
Return 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
Param | Type | Description |
$is_case_insensitive | bool | Defaults to false. |
$tx_name | string | The 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
Description
Fires whenever an import record is SKIPPED.
Parameters
Param | Type | Description |
$post_to_update_id | int | The post ID, or 0 if there's no post. |
$import_id | int | The import ID. |
$current_xml_node | array | An 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.
wp_all_import_single_image_uploads_dir
Description
This action fires every time an image is imported. Can be used to set a custom path in which images (as well as media intended for ACF fields) gets uploaded. Only applies to media uploaded via WP All Import. The main difference from wp_all_import_images_uploads_dir is that it includes the old image URL as a parameter.
Parameters
Param | Type | Description |
$uploads | array | Contains information related to the WordPress uploads path & URL. |
$image_url | string | Contains the imported image URL. |
$articleData | array | Contains a list of data related to the post/user/taxonomy being imported. |
$current_xml_node | array | Array of data for current import record. |
$import_id | int | The import ID that's running. |
$post_id | int | The post ID that's being imported. |
Usage
add_filter( 'wp_all_import_single_image_uploads_dir', 'wpai_wp_all_import_single_image_uploads_dir', 10, 6 );
function wpai_wp_all_import_single_image_uploads_dir( $uploads, $image_url, $articleData, $current_xml_node, $import_id, $post_id ) {
// Do something with code here.
return $uploads;
}
Search the docs for wp_all_import_single_image_uploads_dir
to see real-world code snippets that use this hook.
wp_all_import_single_attachment_uploads_dir
Description
This action fires every time an attachment is imported. Can be used to set a custom path in which attachments are uploaded. The main difference from wp_all_import_attachments_uploads_dir is that it includes the old attachment URL as a parameter.
Parameters
Param | Type | Description |
$uploads | array | Contains information related to the WordPress uploads path & URL. |
$attachment_url | string | Contains the imported attachment URL. |
$articleData | array | Contains a list of data related to the post/user/taxonomy being imported. |
$current_xml_node | array | Array of data for current import record. |
$import_id | int | The import ID that's running. |
Usage
add_filter( 'wp_all_import_single_attachment_uploads_dir', 'wpai_wp_all_import_single_attachment_uploads_dir', 10, 5 );
function wpai_wp_all_import_single_attachment_uploads_dir( $uploads, $attachment_url, $articleData, $current_xml_node, $import_id) {
// Do something with code here.
return $uploads;
}
Search the docs for wp_all_import_single_attachment_uploads_dir
to see real-world code snippets that use this hook.
wp_all_import_before_variable_product_import
Description
This action provides the ID of the parent product before parent data is synced to variations.
Parameters
Param | Type | Description |
$product_id | int | The parent product ID. |
Usage
function my_before_variable_product_import($product_id) {
$import_id = wp_all_import_get_import_id();
// Only run for import ID 5.
if ($import_id == '5') {
// Do something.
}
}
add_action('wp_all_import_before_variable_product_import', 'my_before_variable_product_import', 10, 1);
Search the docs for wp_all_import_before_variable_product_import
to see real-world code snippets that use this filter.