In the previous post, I began sharing how to download user email addresses via JSON in WordPress (using Ajax). The first article covered:
- getting the users’ email addresses,
- and parsing out the results.
There’s more to do, though. Namely:
- converting the returned information into JSON,
- writing that file to disk,
And that’s what the remainder of this post is going to cover. So if you haven’t read the preceding article, I recommend it if for no other reason than to glance at the code to see it thus far.
Say you’re working on a project in which you want to provide the user the ability to download all of the email addresses from the users that exist in the WordPress installation. Granted, this has a few requirements:
- You only want administrators to do it,
- It needs to be secure via nonce values,
- The responses should be in JSON,
Each of the above concepts has likely been covered here before, but what if you’re looking to tie them all together? That is, what if you want to make it easy to download user email addresses via JSON within WordPress from, say, an administration menu or a submenu?
An obligatory shot of where I’m working while writing this post.
Here’s one way to tackle that problem. Note that it does assume you have some knowledge of the above, but I’ll do what I can to cover each of the above.