0

I'm writing a plugin that creates a custom table holding data which is linked to a user account with a user_id field. Now if that users account would be deleted for any reason I would like to set that user_id field in my custom table to 0 to keep the stored data in an anonymized fashion.

Since the first user ID is 1 and counted upwards from there I would assume this is save. Is there any reason why this might have unwanted side effects?

Also, if I would add key constraints to my custom table this would obviousle be a problem when 0 is not existent in wp_users. Would it be hazardous to add a fake user record with id 0 to wp_users?

1 Answer 1

0

I think I found the most semantic solution: If I want to relate a given row of data to "nowhere", NULL is the best value to reflect that. And it even works with constraints on the field!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.