How to display the current and parent category in WordPress
Need to show the category hierarchy in your theme? Learn how to get the current category and its parent using get_the_category() and get_category_parents().
A PHP project that holds personal data usually has three copies of it: production, a staging site and a backup. Datatilsynet’s guidance on security of processing, in Danish “behandlingssikkerhed”, speaks to what happens in each. I am Mariusz Szatkowski, a developer in Gdynia on the same time zone as Copenhagen. I work remotely and in writing, and I have worked with WordPress since 2006. This page applies two Datatilsynet pages to PHP work: the one on test data and the one on deletion. The guidance is addressed to controllers, so the legal decisions stay with you and your data protection adviser. I am not a lawyer.

Rundetaarn in Copenhagen. Photo: Dietmar Rabich, CC BY-SA 4.0, Wikimedia Commons, shown here as a Copenhagen landmark.
Datatilsynet’s page on test data says it can be justified and necessary to use personal data when developing and testing IT systems. Its examples: final tests of integrations between systems, and cases where it is very hard to create realistic anonymised test data, because otherwise it can be difficult to find all errors that occur in production. Earlier in development, a limited number of personal data may be justified for troubleshooting, but under strict rules on access rights and with clean-up afterwards. The closer a system gets to production, the more justified more production data can be. The page even says it can express a lack of security to put a system into production without having tested with production data first.
The page names four things to keep in view when production data is used for testing:
The page adds that data from production does not get a lower level of protection because it is used for testing. It is still processing of personal data.
For a PHP project this is a policy question before it is a technical one. If the answer to “may we copy the live database to staging?” is yes, it should be a yes with a stated reason, a defined data scope and a deletion date, written down by the controller. The default I would propose is the other way round: staging starts with fictional or pseudonymised data, and real data enters only for a defined test.
The guidance says that, as a starting point, the test environment should have the same security measures as are appropriate in the later production environment. It names access control, logging, secure transfer of data between IT environments and security updates of software and servers (patching). It also says it makes a difference which network the test environment is accessible from, and whether it can be reached from the internet.
That sentence describes a lot of real staging sites. A staging copy with a basic password on a public hostname, no logging, an old PHP version and a database dump from last week is the opposite of it. A checklist that follows from the page:
noindex plus authentication where not.Datatilsynet also says pseudonymisation is particularly relevant in development and test environments, since knowledge of specific persons is often not decisive for the test. In practice a sanitising step runs between the dump and the import: names, emails and addresses replaced with consistent fake values, free-text fields emptied, and order and invoice data kept in shape.
<?php
// Replace identifying columns with stable fake values during import.
// $pdo is an existing PDO connection to the staging database.
$update = $pdo->prepare(
'UPDATE customers SET name = :name, email = :email, phone = NULL WHERE id = :id'
);
foreach ($pdo->query('SELECT id FROM customers') as $row) {
$update->execute([
':id' => $row['id'],
':name' => 'Customer ' . $row['id'],
':email' => 'customer' . $row['id'] . '@example.invalid',
]);
}A script like this is the easy part. The work is knowing every place personal data sits: order notes, uploads, log tables, search indexes, cached pages and webhook payload tables. If a new table is added and the sanitiser does not know it, the staging copy quietly contains live data again. A test that fails when a staging database contains an email address outside the reserved test domain catches that.
The page has one more rule for a project that grows up in place. Where the test environment later becomes the production environment, all personal data that was used only for testing must be deleted before the switch.
Datatilsynet’s page on deletion defines the term. Deletion in an IT system is an action that makes the data no longer available. If the data can still be reached by the system administrator after deletion, it is not real deletion. If the data has been deleted through the operating system and is waiting on disk to be overwritten, it counts, because it is no longer reachable by reasonable means.
The page then describes the PHP habit directly. A system can be split into a database that holds everything and a user-facing part that shows and edits it. Some systems use a “soft delete”, where deletion in the user-facing part removes the link but not the personal data in the database. Datatilsynet’s words: this is not real deletion, since the data can still be reached through the database, outside the user-facing part.
Soft delete flags are a normal pattern in PHP applications and ORMs. They have good uses, such as undoing a mistake. They do not satisfy a deletion duty. The usual compromise is a two-step design: the flag hides the record immediately, and a scheduled job removes the row and its dependent data for good after a set period. The period is a decision for the controller, taken per processing and documented.
Datatilsynet gives a design tip with a webshop example. When the controller lays out processing with deletion periods in mind, each period can be tied to a part of the system. In the example, invoices are kept for one period, and the customer’s other data sits in the profile so that it can be deleted together when its period ends. The point is not the figures in that example. It is that a system where each retention period maps to one place is easy to clean, and a system where invoice data, profile data and notes are tangled together is not.
For a PHP application this suggests a few rules:
DELETE statement.The page also asks for a deletion procedure that runs from the moment data reaches its deadline until deletion is carried out and confirmed. It names organisational points, such as who is responsible for starting the deletion and how completion is documented, and technical points, such as whether deletion is automatic or manual and which fields are affected, including the option of anonymising only the identifying fields.
It also says not to trust blindly that deletion runs work. A follow-up procedure can include reviewing technical logs from deletion runs and automated extracts of data that should have been deleted according to the deadline, for manual review.
<?php
// Nightly job: list rows that are past their deletion date, delete, then verify.
// $pdo is an existing PDO connection.
$due = $pdo->query(
'SELECT id FROM customer_profiles WHERE delete_after < CURRENT_DATE'
)->fetchAll(PDO::FETCH_COLUMN);
$delete = $pdo->prepare('DELETE FROM customer_profiles WHERE id = :id');
$log = $pdo->prepare(
'INSERT INTO deletion_log (table_name, row_id, deleted_at) VALUES (:t, :id, NOW())'
);
foreach ($due as $id) {
$delete->execute([':id' => $id]);
$log->execute([':t' => 'customer_profiles', ':id' => $id]);
}
// Follow-up: this count should be zero on the next run.
$left = (int) $pdo->query(
'SELECT COUNT(*) FROM customer_profiles WHERE delete_after < CURRENT_DATE'
)->fetchColumn();The log records the table and row number, not the person. That matches the next point.
Datatilsynet notes that many systems log the actions performed, including deletions, and that those logs can themselves contain personal data, so deletion periods are needed for the logs too. For a PHP project that includes web server access logs, application error logs, queue tables and anything that writes request bodies. A framework debug mode that prints form input into a log file is a deletion problem as well as a security one.
On backups the page is specific. Since a backup exists to restore data, there will be situations where data deleted from the live system still sits in a backup. The controller should deal with that. Datatilsynet’s view is that personal data should be deleted from backups if technically possible, for example where a backup is an uncompressed copy of a database in which deletion can be done in the same way as in the live system. If it is not technically possible to delete single items from a backup, the controller must make sure that data deleted from the live system is removed again if the backup is restored. This may require a log of deletions made in the live system relative to the time a backup was created. Following data minimisation, the page says such a log should not hold directly identifying data, but can state, for example, that a given row in a table was deleted at a given time. The code above does exactly that.
A restore procedure for a PHP application should therefore include a step: after restoring, replay the deletion log from the backup date. A restore test that includes that step is worth more than a restore test that only checks that the site loads.
Datatilsynet also notes that a request under the right to be forgotten can oblige the controller to delete before the planned period ends. There is no duty to document such requests, but some controllers choose, under the accountability principle, to keep a log of them with the outcome and the date of deletion, and that log needs a reasonable deletion period of its own.
Everything legal. The page tells controllers to find the legal basis for processing, to set deletion periods per purpose, to document them and to take account of legal requirements that affect them. A developer cannot decide those. I can ask the questions in the right order and build what the answers require: a sanitising step, a retention date column, a deletion job, a deletion log and a restore procedure. Where the risk to data subjects is assessed as high, the test data page says a data protection impact assessment must be carried out. Whether that applies to your system is for you and your adviser.
Other PHP work I take on is listed on the PHP developer page.
If your Copenhagen team has a staging copy of live data, a soft delete that never becomes a real one, or a backup routine nobody has tested against deletions, send the application, the hosting and the environments through the contact form. There is no charge for the first written estimate on that cleanup. Retention periods and the legal basis for test data are for your controller and adviser to settle.
Examples of my work.
The olshtyn.com website is a modern information portal created with the residents and tourists of Olsztyn in mind. This project combines functionality with a...
Osemka.pl (also known as 8.pl) is a social network that was designed and implemented in 2006-2007 as a place for user integration in the era of early social ...
Photo Studio Balbriggan is a modern photography centre in Ireland offering professional photography services, advanced photo editing, high-quality printing, studio rental, and photography workshops.
Describe your project by e-mail. I reply within 24 hours.
Describe your projectNeed to show the category hierarchy in your theme? Learn how to get the current category and its parent using get_the_category() and get_category_parents().
Need to get the URL of the first image or link in an article? Prefer DOMDocument over regex. Ready-made WordPress PHP for developers.
On 1 December 2026 Taylor Otwell shipped the Laravel Rust beta, and Laravel Go followed a day later. What the framework contains, what the 18x benchmark really measures, what happens to Laravel PHP and WordPress, and when a rewrite makes sense.
Custom WordPress engineering and architecture.
Scalable headless, ERP, and AI architecture for enterprise.
Stores, checkout flow, and sales logic.
Stability, updates, and post-launch support.
What the monthly care fee covers and what changes it.
Business process automation around WordPress and company systems.
Headless WordPress, Sanity, Strapi, and Contentful with Astro or Next.js.
Astro, MDX, edge delivery, and Core Web Vitals measured on real traffic.

How to start as a WordPress developer in 2026. Local environment, theme and plugin development, REST API and headless paths, security and Core Web Vitals. A practitioner playbook that does not waste your first month.

WordPress 7.0 with AI Client against Astro 7 with the Rust compiler and Vite 8. Speed, cost, SEO and security compared, plus the real bill for my own Astro 6 to 7 migration.

A detailed comparison table of EmDash CMS and WordPress across architecture, security, plugins, AI features, content model, hosting, and ecosystem maturity.