Delete database row after contact entry is deleted in WordPress
The below code will delete a row from a custom WordPress database table when a contact entry is deleted. The below example will try to match the row based on the email address of the user.
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);
}
}PreviousInsert form data into a custom database tableNextLimited date availability (slots) for your WordPress booking form
Last updated