Posso restaurar um campo de usuário personalizado?

Acabei de excluir acidentalmente um campo de usuário personalizado. Isso significa que ele foi totalmente removido do banco de dados ou ainda está lá?

Se ainda estiver lá, existe alguma maneira de recuperá-lo (além de restaurar um backup)? Ou de acessar o conteúdo por meio do explorador de dados?

I’m 95% sure a deleted custom field is gone forever.

If you can’t see it in data explorer, it’s not there anymore.

Just a thought, but surely there would be a way to recreate the Custom Field and hack together a script to retrieve and refill the data from within a backup using a temporary cloud server to write out the data from the original Custom Field?

Thanks for your thoughts. Yes, that’s obviously what backups are for. I don’t know what the smartest procedure would be for restoring user field content for, say, thousands of users. For me, the number the easiest procedure was to just do it manually. And that was actually surprisingly easy, so I mention it here (from memory, so I may have missed some detail):

  • When you download the backup file and open it for example with good old WinRAR, you’ll find another archive in there, so open that with WinRAR too. You’ll find an .sql file.
  • And now comes the good part: you can just open it as a text file (with the built-in WinRAR viewer or otherwise).
  • Search for the name of the field or some content you hapoen to know and you’ll find the table for that user field.
  • Now the only trickyness is that (at least in my case) the user ID is not the first but the second value in each row (I’d be curious what the first value represents (“COPY”)).

Atualmente, ao excluir um campo personalizado (as tabelas user_fields e user_fields_options, se o field_type for dropdown), os valores reais dos usuários (tabela user_custom_fields) não são excluídos. Portanto, uma solução rápida (mas potencialmente perigosa: faça um backup primeiro) é:

  1. Criar manualmente um novo campo personalizado.
  2. Substituir o novo ID em user_fields pelo ID antigo (isso requer acesso de administrador ao banco de dados): UPDATE user_fields SET id=1 WHERE id=3; (supondo que 3 seja o novo ID e 1 seja o antigo).
  3. Se o campo for do tipo dropdown, será necessário fazer algo semelhante em user_field_options.
  4. Se algum usuário se registrou no seu site e preencheu o novo campo antes de você corrigir o problema (ou se algum usuário existente preencheu o novo campo), você também precisará corrigir esses registros.