> For the complete documentation index, see [llms.txt](https://docs.super-forms.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.super-forms.com/developers/code-examples/delete-database-row-after-contact-entry-is-deleted-in-wordpress.md).

# Delete database row after contact entry is deleted in WordPress

The below code matches based on the `email` column, but you can change this to whatever your usecase might be. For instance if you use unique codes to track entries you can do that as well.

You can also match it based on the `$entry_id` as long as you made sure you stored this when [inserting the row into your custom database](/developers/code-examples/insert-form-data-into-a-custom-database-table.md) which is enabled by default under the column `entry_id`.

```php
add_action('before_delete_post', 'f4d_delete_entry_attachments'); 
function f4d_delete_entry_attachments($entry_id){ 
    if(get_post_type($entry_id)=='super_contact_entry'){ 
        $data = get_post_meta($entry_id, '_super_contact_entry_data', true); 
        // Delete row from database based on application code 
        global $wpdb; 
        $table = 'wp_custom_table'; 
        $where_condition = array('email' => $data['email']['value']); 
        $wpdb->delete($table , $where_condition); 
    } 
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.super-forms.com/developers/code-examples/delete-database-row-after-contact-entry-is-deleted-in-wordpress.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
