Last active
September 24, 2018 16:26
-
-
Save EricBusch/6d32edf85a2a23396d4ae83f08b7c9a7 to your computer and use it in GitHub Desktop.
Set newly imported products' post_status field to 'draft' instead of to 'publish'. Only applies to products being imported for the first time, not to already imported products. [datafeedr][dfrpswc]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Set newly imported products' post_status field to 'draft' instead | |
* of to 'publish'. Only applies to products being imported for the first | |
* time, not to already imported products. | |
* | |
* @param array $post Array containing Post information. | |
* @param array $product Array containing Datafeedr Product information. | |
* @param array $set Array containing Product Set information. | |
* @param string $action Either "update" or "insert" depending on what the Product Set is doing. | |
* | |
* @return array Update $post array. | |
*/ | |
function mycode_import_new_products_as_drafts( $post, $product, $set, $action ) { | |
$post['post_status'] = ( ! isset( $post['ID'] ) ) ? 'draft' : get_post_status( $post['ID'] ); | |
return $post; | |
} | |
add_filter( 'dfrpswc_filter_post_array', 'mycode_import_new_products_as_drafts', 100, 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment