# Writing and deleting

Source: https://uglydev.com/docs/php-api/writing-and-deleting/
Updated: 19 November 2026

```php
ugly_update( 'price', 120 );                 // on the current post
ugly_update( 'price', 120, 42 );             // on post 42

ugly_update( 'team', array(                  // a whole repeater
	array( 'name' => 'Ana',  'role' => 'Chef' ),
	array( 'name' => 'Luis', 'role' => 'Baker' ),
), 42 );

ugly_delete( 'price', 42 );
```

What you write goes through the same cleaning as what the editor writes. A number out of range is cut. A badly typed color is dropped. A value that does not belong is not saved.

Both return `true` when something was written (or deleted) and `false` when it was not.

## A common recipe: add one row to a repeater

Rows come out as objects, so convert each one to an array, add yours, and write the list back:

```php
$rows = array_map(
	static fn ( $row ) => $row->toArray(),
	ugly_rows( 'team', 42 )
);

$rows[] = array( 'name' => 'Marta', 'role' => 'Waiter' );

ugly_update( 'team', $rows, 42 );
```

> **Note:** the rows that `ugly_get()` gives can also be written back with `ugly_update()` as they are.
