Skip Navigation

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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 -

Supporter timezone: Asia/Singapore (GMT+08:00)

Tagged: 

This topic contains 7 replies, has 2 voices.

Last updated by Kor 9 months ago.

Assisted by: Kor.

Author Posts
June 6, 2024 at 4:45 pm #15712701

aleksandreK

Background of the issue:
WPML still detects some custom fields from the plugins that were removed very long time ago. Can it be cleand up? For example b2b
king plugin.

Symptoms:
WPML still detects some custom fields from the plugins that were removed very long time ago. Can it be cleand up?

Questions:
WPML still detects some custom fields from the plugins that were removed very long time ago. Can it be cleand up?

June 7, 2024 at 7:41 pm #15717723

Kor
Supporter

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Thanks for your patience.

I have escalated this to our 2nd Tier Support and I will come back to you once I've feedback.

June 13, 2024 at 10:53 am #15735659

Kor
Supporter

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Thank you for your patience. I've received feedback from our 2nd Tier Support, and here's what they've mentioned:

The custom fields still persist in the database, so they will continue to appear in that section. WPML lacks a mechanism to determine if a plugin has been deleted or not.

In this scenario, the user would have to manually remove them from the database or verify if the Ultimate WooCommerce B2B & Wholesale Plugin offers an uninstall option.

June 16, 2024 at 7:34 am #15742304

aleksandreK

Thanks. Can you provide some workaround how it's possible to filter fields in the DB of the removed plugins and remove them?

June 16, 2024 at 9:06 pm #15743045

Kor
Supporter

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Thanks for your reply.

I'll check with our 2nd Tier Support to see if there is an easy way to remove these fields from the database. I will come back to you once I've feedback.

June 17, 2024 at 2:48 pm #15746172

Kor
Supporter

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Thank you for your patience. Here is the feedback from our 2nd Tier Support:

We have generated this snippet using ChatGPT. The suggestion is to insert it into the functions.php file and replace 'custom_field_1'... with the specific fields he wishes to remove.

However:

Please note that this falls outside the scope of WPML support.
We strongly recommend testing this on a staging website first and performing a full backup.

function remove_custom_fields_by_key($meta_keys = []) {
    global $wpdb;
    if (empty($meta_keys)) {
        return; // No meta keys provided
    }

    foreach ($meta_keys as $key) {
        $query = $wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE meta_key = %s", $key);
        $wpdb->query($query);
    }
}

// Usage
add_action('wp_loaded', function() {
    remove_custom_fields_by_key(['custom_field_1', 'custom_field_2']);
});
June 20, 2024 at 5:29 pm #15765806

aleksandreK

Did you test it and it worked for you?

June 20, 2024 at 6:06 pm #15765945

Kor
Supporter

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Thank you for your response. Unfortunately, we haven't tested this as it's beyond the scope of our current support offerings. Our second-tier support has provided some methods for you to try instead.

DISCLAIMER: Please know that any snippet or code suggested here is for educational purposes only. they are not meant to be the final solution but instead meant to point you in the right direction and are out of the scope of our support so we can't nor will modify, improve, debug or maintain it.

The topic ‘[Closed] WPML still detects some custom fields from the plugins that were removed very long time ago. Can it …’ is closed to new replies.