• g2lyon

    (@g2lyon)


    Hello,
    Is there a way to disable deletion of a specific custom field ?
    Something like:

    add-action('some_event_related_to_customfields', function(){
     sommething_postmeta('my-metakey', [' allow-delete' => false]});

    May be too simplistic ?

    This question refers to native custom fields, not “ACF” or “Carbon Fields” (I know the way for these types of fields)

    • This topic was modified 3 years ago by g2lyon.
    • This topic was modified 3 years ago by g2lyon.
Viewing 2 replies - 1 through 2 (of 2 total)
  • swayam.tejwani

    (@swayamtejwani)

    As I know, custom field only deletes when you delete the post, if you want to keep it then you can insert the custom field data in some other custom table other then wp_postmeta and you need to update the custom field if post updates so there will be a sync but it wont delete as the data is now in custom table as well.

    Thread Starter g2lyon

    (@g2lyon)

    @swayamtejwani
    I now understand that as long as some posts are using a custom field key it cannot be deleted (without coding).
    It’s sufficient for my needs.
    Thank you

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘how to prevent custom fields deletion ?’ is closed to new replies.