Created
April 21, 2024 16:16
-
-
Save juanlistab/ca69fda232be251f19d1e9ed1e8af94c to your computer and use it in GitHub Desktop.
Revisions
-
juanlistab created this gist
Apr 21, 2024 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ # Workaround for preventing the Customers Import to delete other user role accounts This function will prevent the Customers Import from deleting other user roles such as Shop Manager when run with the "Remove users not present in this import file" option. ```php function is_post_to_delete_on_meta($is_post_to_delete, $pid, $import) { // Check if the current user has the 'shop_manager' role if ( user_can( $pid, 'shop_manager' ) ) { // If the user is a shop manager, don't delete the record return false; } // If the user is not a shop manager, allow deletion of the record return true; } add_filter('wp_all_import_is_post_to_delete', 'is_post_to_delete_on_meta', 10, 3); ```