This is the technical support forum for WPML - the multilingual WordPress plugin.
Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.
Tagged: Compatibility, Custom Work
This topic contains 5 replies, has 2 voices.
Last updated by Long Nguyen 1 year, 6 months ago.
Assisted by: Long Nguyen.
Author | Posts |
---|---|
July 24, 2023 at 7:51 am #14086605 | |
Insignia |
Hello, I'm using WPML extension for WP All Import PRO, works great, the problem is I need to activate the option to delete all registers not found in current import, doing this the plugin deletes the WPML translations also, is there a way to fix this? |
July 24, 2023 at 8:17 am #14086809 | |
Long Nguyen Supporter
Languages: English (English ) Timezone: Asia/Ho_Chi_Minh (GMT+07:00) |
Hi, Here is the ticket. Please let me know steps to replicate the issue and share the import file afterward. Look forward to your reply. |
July 24, 2023 at 9:20 am #14087613 | |
Insignia |
Hello Long, Plese check the imports on the dev site, if you try to import the catalan one you'll see all spanish translations disappear as it has the mark to "delete all posts not found in the import file" I hope this option could skip the translation deletion Thanks |
July 24, 2023 at 10:27 am #14088309 | |
Long Nguyen Supporter
Languages: English (English ) Timezone: Asia/Ho_Chi_Minh (GMT+07:00) |
Hi, If you use the options: You can use the filter hook "wp_all_import_is_post_to_delete" to check the language of the post ID and skip the deletion if it is Spanish (es). For example: add_filter( 'wp_all_import_is_post_to_delete', function( $to_delete, $post_id, $wpallimport_record ) { $post_language_details = apply_filters( 'wpml_post_language_details', NULL, $post_id ); $post_language = $post_language_details['language_code']; if ( $post_language == 'es' ) { $to_delete = false; } return $to_delete; }, 10, 3 ); ❌ IMPORTANT: Please backup your database and website before proceeding ❌ Related documentation Note: I would like to inform you that helping you with custom code, is out of the scope of WPML, but I can point you to some useful documentation. Look forward to your reply. |
July 24, 2023 at 10:31 am #14088335 | |
Insignia |
Hello Long, Oh that's perfect, one more thing, is there a way to detect the language of the current running import? Because I would need to do this with all the imports, the logic would be, if the post is the same language as the import, $to_delete if not false |
July 25, 2023 at 3:38 am #14092889 | |
Long Nguyen Supporter
Languages: English (English ) Timezone: Asia/Ho_Chi_Minh (GMT+07:00) |
Hi, With the custom code above, you can try to use the code below to get the current import process language. add_filter( 'wp_all_import_is_post_to_delete', function( $to_delete, $post_id, $wpallimport_record ) { // Get import process language $import_process_language = $wpallimport_record->options['wpml_addon']['lng']; // Do your stuff return $to_delete; }, 10, 3 ); Note: I would like to inform you that helping you with custom code, is out of the scope of WPML. If you are not able to accomplish this, I would recommend you contact one of our certified partners that will be more than happy to help you with this. In this link you will find a list of our certified partners: https://wpml.org/contractors/ Thanks. |