Answer the question
In order to leave comments, you need to log in
update_post_meta doesn't work. What am I doing wrong?
In the code below, update_post_meta does not work.
function edit_servise( /*$servise_id, $current_servise_key, $current_servise_label, $current_servise_cost, $upd_servise_label, $upd_servise_cost*/ ){
global $wpdb;
if( isset($_POST['servise_id']) and isset($_POST['current_servise_key']) and isset($_POST['current_servise_label']) and isset($_POST['current_servise_cost']) and isset($_POST['upd_servise_label']) and isset($_POST['upd_servise_cost']) ){
$servise_id = $_POST['servise_id'];
$current_servise_key = $_POST['current_servise_key'];
$current_servise_label = $_POST['current_servise_label'];
$current_servise_cost = $_POST['current_servise_cost'];
$upd_servise_label = $_POST['upd_servise_label'];
$upd_servise_cost = $_POST['upd_servise_cost'];
$upd_label = update_post_meta( $servise_id, "_".$current_servise_key, $upd_servise_label, $current_servise_label );
if ($upd_label){ $label_msg = 'Название изменено успешно !';} else {$label_msg="Название изменено не было..";}
$upd_cost = update_post_meta( $servise_id, $current_servise_key, $upd_servise_cost, $current_servise_cost );
if($upd_cost){ $cost_msg = 'Стоимость услуги обновлена !';} else {$cost_msg=" Стоимость осталась прежней..";}
echo 'Ответ сервера: '.$label_msg.', новое название '.$upd_servise_label.' текущее название '.$current_servise_label.' | ключ '.$current_servise_key.' сообщение стоимости '.$cost_msg;
}
else {echo 'Упс.. Что-то пошло не так..';}
}
Answer the question
In order to leave comments, you need to log in
Just call delete_post_meta( $post_id, $key, $value ); and you will be happy
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question