Building an email signup form. Where should the information be saved in the DB?

I would like to try build a simple plugin that collects and stores the name and email address of the person who filled in the form. I realize there are probably dozens of plugins out there that do this already but would like to build my own, for practice.

If the user enters their name and email address, where should this be stored? Should it be created as a “subscriber” custom post type or a whole new table in the WP database? What are your thoughts? I’d like to eventually export the data to a .csv file if that influences where it should be stored.

Related posts

Leave a Reply

1 comment

  1. There are multiple storage mechanisms in WP so it can be bit tricky to pick one and sometimes there is no single right choice.

    Let’s examine your criteria for storage:

    • persistent (you don’t want data just evaporating)
    • processable (you want to export it and probably navigate)
    • simple to implement (you don’t want go building something (semi)custom just for the heck of it)
    • extensible (in case you want to capture more data down the road and such)

    As for me the best storage to satisfy these condition would be using custom post type. It comes with a lot of functionality out of the box (like admin interface), requires no messing with storage (custom tables or whatever) and is perfectly suited to store arbitrary information in custom fields.