I have plugin function where I want to delete specific postmeta if they're exists in every posts based on condition (which is fulfilled with my testing post) but it didn't delete the metadata..
The code:
add_action('init', 'survey_start_type_validation');
function survey_start_type_validation($post_id)
{
$type_of_running = get_post_meta($post_id, 'spusteni_dotazovani');
if($type_of_running == 'manually_run') {
if(metadata_exists('survey', $post_id, 'datum_a_cas_planovaneho_spusteni') == true) {
delete_post_meta($post_id, 'datum_a_cas_planovaneho_spusteni');
delete_post_meta($post_id, '_datum_a_cas_planovaneho_spusteni');
}
} elseif($type_of_running == 'planned_run') {
if(metadata_exists('survey', $post_id, 'running_status') == true) {
delete_post_meta($post_id, 'running_status');
delete_post_meta($post_id, '_running_status');
}
}
}
Have anyone some advice?
source https://stackoverflow.com/questions/70635208/wordpress-plugin-function-didnt-delete-the-post-meta
Comments
Post a Comment