<?
if (isset($_GET['editar'])) {
$post_id = intval($_GET['editar']);
$post = get_post($post_id);
if ($post->post_author != $user_id) {
return "<p>No autorizado</p>";
}
?>
<h3>Editar Inmueble</h3>
<form method="post">
<input type="text" name="titulo" value="<?php echo esc_attr($post->post_title); ?>"><br><br>
<textarea name="descripcion"><?php echo esc_textarea($post->post_content); ?></textarea><br><br>
<button name="actualizar">Actualizar</button>
</form>
<?php
if (isset($_POST['actualizar'])) {
wp_update_post([
'ID' => $post_id,
'post_title' => $_POST['titulo'],
'post_content' => $_POST['descripcion']
]);
echo "<p>✅ Actualizado</p>";
}
}